Factorial Calculator

Calculate n! factorials, nPr permutations, and nCr combinations for any positive integer up to 170.

🔢 Factorial Calculator
n (whole number, 0 to 170)
r (items to choose, 0 ≤ r ≤ n)
10! =
Expansion

🔢 What is a Factorial?

Factorial is the product of all positive integers from 1 up to a given number n. It is written as n! and pronounced "n factorial." For example, 5! = 5 × 4 × 3 × 2 × 1 = 120, and 10! = 3,628,800. By mathematical definition, 0! = 1 because there is exactly one way to arrange zero objects, and this definition keeps all combinatorial formulas consistent. The factorial function is defined only for non-negative integers.

Factorials appear throughout mathematics, statistics, and science. In combinatorics, n! gives the number of distinct orderings (permutations) of n objects: 3 books can be arranged on a shelf in 3! = 6 ways. In probability, factorials appear in binomial coefficients, which count the number of ways to choose k successes in n trials. In calculus, factorials appear in Taylor series and power series expansions: e^x = 1 + x + x²/2! + x³/3! + ...

This calculator covers three closely related computations. Factorial (n!) finds the product of all integers from 1 to n. Permutation (nPr) counts ordered arrangements: nPr = n! / (n-r)!, used when the order of selection matters (first place, second place, third place are distinct outcomes). Combination (nCr) counts unordered selections: nCr = n! / (r! × (n-r)!), used when only the membership of the group matters and not the order in which members were chosen.

A common source of confusion is whether to use permutation or combination. The key question is: does swapping two selected items create a different outcome? If yes (a lock combination where 1-2-3 differs from 3-2-1), use permutation. If no (a committee where the same three people form the same committee regardless of selection order), use combination. The relationship between them is nCr = nPr / r!, because dividing by r! removes the r! different orderings of the same group.

📐 Formula

n! = n × (n−1) × (n−2) × … × 2 × 1
n = non-negative integer (0 to 170 for this calculator)
0! = 1 (by definition)
Example: 5! = 5 × 4 × 3 × 2 × 1 = 120
nPr = n! ÷ (n − r)!
n = total number of distinct items
r = number of items to select (r ≤ n)
Example: 5P3 = 5! ÷ (5−3)! = 120 ÷ 2 = 60
nCr = n! ÷ (r! × (n − r)!)
n = total number of distinct items
r = number of items to select (r ≤ n)
Relationship: nCr = nPr ÷ r!
Example: 5C3 = 5! ÷ (3! × 2!) = 120 ÷ (6 × 2) = 10

📖 How to Use This Calculator

Steps

1
Select a mode using the tabs at the top: n! Factorial for a simple factorial, nPr Permutation for ordered arrangements, or nCr Combination for unordered selections.
2
Enter n in the first field (any whole number from 0 to 170). For permutation and combination modes, also enter r in the second field (must satisfy 0 ≤ r ≤ n).
3
Click Calculate to see the result. For n ≤ 15 in factorial mode, the full expansion (1 × 2 × … × n) is also shown.

💡 Example Calculations

Example 1 — Factorial of 7

Find 7! (how many ways can 7 runners finish a race?)

1
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1
2
= 42 × 5 × 4 × 3 × 2 × 1 = 210 × 24 = 5,040
7! = 5,040
Try this example →

Example 2 — Permutation 10P3 (top-3 finish from 10 runners)

How many ordered ways can 3 runners finish in first, second, and third place from a field of 10?

1
nPr = n! ÷ (n − r)! = 10! ÷ (10 − 3)! = 10! ÷ 7!
2
= (10 × 9 × 8 × 7!) ÷ 7! = 10 × 9 × 8 = 720
10P3 = 720 ordered podium finishes
Try this example →

Example 3 — Combination 52C5 (5-card poker hands)

How many distinct 5-card hands can be dealt from a standard 52-card deck?

1
nCr = n! ÷ (r! × (n−r)!) = 52! ÷ (5! × 47!)
2
= (52 × 51 × 50 × 49 × 48) ÷ (5 × 4 × 3 × 2 × 1) = 311,875,200 ÷ 120
52C5 = 2,598,960 distinct poker hands
Try this example →

Example 4 — Combination 8C2 (pairs from a group)

How many pairs can be formed from a group of 8 people?

1
8C2 = 8! ÷ (2! × 6!) = (8 × 7) ÷ (2 × 1) = 56 ÷ 2
8C2 = 28 unique pairs
Try this example →

❓ Frequently Asked Questions

What is a factorial in math?+
A factorial (written n!) is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials count the number of ways to order n distinct objects. By convention, 0! = 1 because there is exactly one way to arrange zero items.
Why does 0 factorial equal 1?+
0! = 1 by definition. The most intuitive explanation: there is exactly one way to arrange zero objects, which is the empty arrangement. Mathematically, the definition keeps the recursive formula n! = n × (n-1)! valid at n=1: 1! = 1 × 0! = 1 × 1 = 1. Without this, formulas like nC0 = n! / (0! × n!) = 1 would fail.
What is the difference between permutation and combination?+
Permutation (nPr) counts ordered selections: choosing 3 gold-silver-bronze medalists from 10 athletes gives 10P3 = 720 because the order (who gets gold vs. silver) matters. Combination (nCr) counts unordered selections: choosing 3 committee members from 10 gives 10C3 = 120 because the group is the same regardless of selection order. nCr = nPr / r! because each group of r items can be ordered r! ways.
What is 10 factorial?+
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800. This is the number of ways to arrange 10 distinct items in a line. For context: a standard deck of 52 cards can be shuffled in 52! arrangements, a number with 68 digits that vastly exceeds the number of atoms in the observable universe.
What is the formula for permutation nPr?+
nPr = n! / (n-r)!. For 8P3: 8! / 5! = (8 × 7 × 6 × 5!) / 5! = 8 × 7 × 6 = 336. The denominator cancels the shared factorial tail, leaving only the top r terms of n!. This is also written P(n,r) or P_n^r in some textbooks.
What is the formula for combination nCr?+
nCr = n! / (r! × (n-r)!). For 8C3: 8! / (3! × 5!) = (8 × 7 × 6) / (3 × 2 × 1) = 336 / 6 = 56. The extra r! divides out the orderings of the selected items, leaving the count of distinct subsets. Also written C(n,r) or the binomial coefficient "n choose r."
What is the largest factorial I can calculate here?+
This calculator supports up to 170!. The value 170! is approximately 7.257 × 10^306, which is the largest factorial that fits in a JavaScript double-precision floating-point number. Values from about 21! onwards are returned in scientific notation (e.g., 4.2749e+19) because they exceed JavaScript's integer precision limit of 2^53.
How many ways can you arrange 5 objects?+
5! = 120 ways. The first position can be filled by any of the 5 objects, the second by any of the remaining 4, and so on: 5 × 4 × 3 × 2 × 1 = 120. More generally, n distinct objects can be arranged in n! ways, which is the full permutation nPn = n!.
Is nCr symmetric? Does 10C3 equal 10C7?+
Yes. nCr = nC(n-r) for any valid r. For 10C3 = 10C7: both equal 120. The reason: choosing 3 items to include from 10 is equivalent to choosing 7 items to exclude. This symmetry appears visually in Pascal's triangle, where every row reads identically from both ends.
How is factorial used in probability and statistics?+
Factorials are central to combinatorics and probability. The binomial probability formula P(X=k) = nCk × p^k × (1-p)^(n-k) uses nCk to count favorable outcomes. Normal distribution approximations use Stirling's approximation for large n! (ln(n!) = n ln n - n + 0.5 ln(2πn)). Poisson distribution also involves factorials in its pmf: P(k) = e^(-λ) × λ^k / k!.
What is 52 choose 5 (number of poker hands)?+
52C5 = 52! / (5! × 47!) = 2,598,960. This is the total number of distinct 5-card poker hands from a 52-card deck. Of these, 4 are royal flushes, 36 are straight flushes, 624 are four-of-a-kind hands, and so on. Poker hand probabilities are calculated by dividing each hand count by 2,598,960.