Factorial Calculator
Calculate n! factorials, nPr permutations, and nCr combinations for any positive integer up to 170.
🔢 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
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 — Factorial of 7
Find 7! (how many ways can 7 runners finish a race?)
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?
Example 3 — Combination 52C5 (5-card poker hands)
How many distinct 5-card hands can be dealt from a standard 52-card deck?
Example 4 — Combination 8C2 (pairs from a group)
How many pairs can be formed from a group of 8 people?
❓ Frequently Asked Questions
🔗 Related Calculators
What is a factorial and how is it calculated?
A factorial of n (written n!) is the product of all positive integers from 1 to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. By definition, 0! = 1. Factorials grow extremely quickly: 10! = 3,628,800 and 20! exceeds 2 × 10^18.
What is 0! and why does it equal 1?
0! = 1 by mathematical convention. The reasoning: there is exactly one way to arrange zero objects (do nothing), which gives 0! = 1. This also keeps the recursive formula n! = n × (n-1)! consistent at n=1: 1! = 1 × 0! = 1 × 1 = 1. Without 0! = 1, many combinatorial formulas would break down.
What is the difference between permutation (nPr) and combination (nCr)?
Permutation nPr counts ordered arrangements: choosing 3 from 5 people for first, second, and third place gives 5P3 = 60. Combination nCr counts unordered selections: choosing 3 from 5 people for a committee gives 5C3 = 10. The relationship is nCr = nPr / r! because each unordered group of r items can be arranged r! ways.
What is the formula for permutation nPr?
nPr = n! / (n-r)!. For 5P3: 5! / (5-3)! = 120 / 2 = 60. This counts ordered arrangements of r items chosen from n distinct items. The denominator cancels the factorial of items not chosen, leaving only the product of the top r terms: n × (n-1) × ... × (n-r+1).
What is the formula for combination nCr?
nCr = n! / (r! × (n-r)!). For 5C3: 5! / (3! × 2!) = 120 / (6 × 2) = 10. The extra r! in the denominator (compared to permutation) divides out all orderings of the r selected items, leaving only the count of distinct groups.
What is the largest factorial this calculator can compute?
170! is the largest factorial representable in JavaScript double-precision floating point. 170! is approximately 7.257 × 10^306. The value 171! exceeds Number.MAX_VALUE (about 1.798 × 10^308) and evaluates to Infinity. For exact large factorials, specialized big-integer libraries are required.
How many ways can you arrange n objects?
The number of distinct orderings (permutations) of n objects is n!. For 3 objects (A, B, C): 3! = 6 arrangements (ABC, ACB, BAC, BCA, CAB, CBA). For 5 books on a shelf: 5! = 120 orderings. This is the full permutation nPn = n.
What is 10 factorial (10!)?
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 sequence. It also equals 10P10, the number of ordered arrangements of all 10 items.
How is nCr used in the binomial theorem?
In the expansion of (a + b)^n, the coefficient of the term a^(n-k) × b^k is nCk (read: n choose k). For (a+b)^4: coefficients are C(4,0)=1, C(4,1)=4, C(4,2)=6, C(4,3)=4, C(4,4)=1, giving 1a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4. The sum of all coefficients equals 2^n.
What does nCr equal when r = 0 or r = n?
nC0 = 1 for any n: there is exactly one way to choose zero items (choose nothing). nCn = 1 for any n: there is exactly one way to choose all n items (choose everything). These boundary values follow directly from the formula: n! / (0! × n!) = 1 and n! / (n! × 0!) = 1.
Is nCr the same as nCr when r is swapped with n-r?
Yes. nCr = nC(n-r). For example, 8C3 = 8C5 = 56. Choosing 3 items to include is equivalent to choosing 5 items to exclude. This symmetry appears in Pascal's triangle, where each row reads the same from left to right and right to left.