Factorial Calculator (n!) with Reference Table
The factorial of n, written n!, is the product of every positive integer from 1 up to n. It answers the question: In how many ways can n distinct objects be arranged in order? For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorials grow explosively fast — 20! already exceeds 2.4 quintillion — making this calculator essential for combinatorics, probability, statistics, and computer science problems where exact large-integer results matter.
The factorial of n (written n!) is the product of all positive integers from 1 to n: n! = 1 × 2 × 3 × … × n. Key values: 0! = 1, 5! = 120, 10! = 3,628,800, 20! = 2,432,902,008,176,640,000. Factorial counts the number of distinct ways to arrange n objects in order.
When to use this calculator
- Counting the number of ways to arrange 8 competitors on a podium: 8! = 40,320 possible orderings.
- Calculating permutations of a 13-card hand dealt from a shuffled deck using 52! / 39!.
- Computing binomial coefficients C(n, k) = n! / (k! × (n−k)!) needed for probability distributions and statistical tests.
- Determining the number of unique routes a delivery driver can take visiting 10 stops: (10−1)! = 362,880 circular permutations.
- Evaluating Taylor/Maclaurin series terms such as e^x = Σ (x^n / n!) in calculus and physics simulations.
- Checking hash collision probabilities using the birthday problem approximation involving k! terms.
Example: 6!
- n = 6
- 6! = 6 × 5 × 4 × 3 × 2 × 1 = 720
How it works
3 min readHow It Is Calculated
The factorial function is defined both recursively and iteratively:
Iterative: n! = 1 × 2 × 3 × … × n
Recursive: n! = n × (n−1)! (base case: 0! = 1)
Stirling's Approximation (large n):
n! ≈ √(2πn) × (n/e)^n
where e ≈ 2.71828The convention 0! = 1 ensures combinatorial formulas remain consistent when k = 0 or k = n.
---
Reference Table: Factorial Values 0 to 20
| n | n! | Scientific notation | Digits |
|---|---|---|---|
| 0 | 1 | 1 × 10⁰ | 1 |
| 1 | 1 | 1 × 10⁰ | 1 |
| 2 | 2 | 2 × 10⁰ | 1 |
| 3 | 6 | 6 × 10⁰ | 1 |
| 4 | 24 | 2.4 × 10¹ | 2 |
| 5 | 120 | 1.2 × 10² | 3 |
| 6 | 720 | 7.2 × 10² | 3 |
| 7 | 5,040 | 5.04 × 10³ | 4 |
| 8 | 40,320 | 4.032 × 10⁴ | 5 |
| 9 | 362,880 | 3.629 × 10⁵ | 6 |
| 10 | 3,628,800 | 3.629 × 10⁶ | 7 |
| 11 | 39,916,800 | 3.992 × 10⁷ | 8 |
| 12 | 479,001,600 | 4.79 × 10⁸ | 9 |
| 13 | 6,227,020,800 | 6.227 × 10⁹ | 10 |
| 14 | 87,178,291,200 | 8.718 × 10¹⁰ | 11 |
| 15 | 1,307,674,368,000 | 1.308 × 10¹² | 13 |
| 16 | 20,922,789,888,000 | 2.092 × 10¹³ | 14 |
| 17 | 355,687,428,096,000 | 3.557 × 10¹⁴ | 15 |
| 18 | 6,402,373,705,728,000 | 6.402 × 10¹⁵ | 16 |
| 19 | 121,645,100,408,832,000 | 1.216 × 10¹⁷ | 18 |
| 20 | 2,432,902,008,176,640,000 | 2.433 × 10¹⁸ | 19 |
---
Large Factorial Quick Reference
| n | n! (approx.) | Digits |
|---|---|---|
| 25 | 1.551 × 10²⁵ | 26 |
| 50 | 3.041 × 10⁶⁴ | 65 |
| 100 | 9.333 × 10¹⁵⁷ | 158 |
| 170 | 7.257 × 10³⁰⁶ | 307 |
| 171 | overflow | exceeds double-precision floating point |
> Number of digits in n! ≈ n·log₁₀(n/e) + ½·log₁₀(2πn) — for n = 1,000 that is 2,568 digits.
---
Worked Examples
Permutations — arranging a playlist of 7 songs in every possible order:
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5,040 unique orderings.
Combinations — choosing a 5-person committee from 10 candidates:
C(10, 5) = 10! / (5! × 5!) = 3,628,800 / (120 × 120) = 252 distinct committees.
Probability — how unique is a shuffled deck of 52 cards?
Total distinct orderings: 52! ≈ 8.066 × 10⁶⁷ — essentially every fair shuffle in history is a unique event.
Taylor series — computing e¹:
e¹ = 1/0! + 1/1! + 1/2! + 1/3! + … = 1 + 1 + 0.5 + 0.1667 + … ≈ 2.71828
---
Common Mistakes
1. Assuming 0! = 0. The factorial of zero is 1 — required for consistent combinatorial formulas.
2. Applying factorials to negative integers. n! is undefined for negative integers in the standard definition.
3. Applying factorials to non-integers. 3.5! requires the Gamma function: Γ(4.5) ≈ 11.632.
4. Integer overflow in code. C (32-bit int) overflows at 13!. Use 64-bit integers up to 20!, or arbitrary-precision for larger values.
5. Confusing n! with n^n. 5! = 120 but 5^5 = 3,125.
---
Related Calculators
Frequently asked questions
Why does 0! equal 1 and not 0?
0! = 1 is a definition required for combinatorial formulas to remain consistent. The number of ways to arrange zero objects is exactly 1 (the empty arrangement). Without this convention, C(n, 0) = n!/(0! × n!) would be undefined instead of correctly equaling 1.
What are the factorial values from 1 to 10?
1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, 6! = 720, 7! = 5,040, 8! = 40,320, 9! = 362,880, 10! = 3,628,800. Each value equals the previous one multiplied by n: 6! = 6 × 5! = 6 × 120 = 720.
What is the largest factorial a standard calculator can compute exactly?
A 64-bit integer (uint64) holds values up to 2^64 − 1 ≈ 1.84 × 10^19, accommodating up to 20! (≈ 2.43 × 10^18) exactly but overflowing at 21!. This calculator uses double-precision floating point and works accurately up to 170! (≈ 7.26 × 10^306); 171! exceeds the double-precision maximum.
How fast do factorials grow compared to exponential functions?
Factorials grow faster than any fixed exponential base. For large n, n! grows faster than 2^n, 10^n, or even 1,000^n. Stirling's approximation shows n! ≈ √(2πn)(n/e)^n — a super-exponential growth rate. For comparison, 20! = 2.43 × 10^18 while 2^20 = only 1,048,576.
What is Stirling's approximation and when should I use it?
Stirling's approximation is n! ≈ √(2πn) × (n/e)^n. Use it when n is large and an exact value is impractical to compute by hand — for example in statistical mechanics, information theory, and asymptotic algorithm analysis. Its relative error drops below 1% for n ≥ 3 and below 0.1% for n ≥ 10.
Can I compute the factorial of a decimal like 2.5!?
Not with the standard n! definition, which requires non-negative integers. For non-integer values, use the Gamma function: Γ(n+1) = n!, so 2.5! = Γ(3.5) ≈ 3.3234. The Gamma function is available in Python as math.gamma(3.5), in R as gamma(3.5), and in Wolfram Alpha.
How many digits does 100! have?
100! has exactly 158 digits and starts with 9.332 × 10^157. Estimate the digit count using Stirling: log₁₀(n!) ≈ n·log₁₀(n/e) + 0.5·log₁₀(2πn). For n=100 this gives ≈ 157.97, so 158 digits. 100! also ends in exactly 24 trailing zeros.
How many trailing zeros does n! have?
Count trailing zeros using Legendre's formula: ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … (sum of integer divisions by powers of 5). For n=100: 20 + 4 = 24 zeros. For n=1000: 200 + 40 + 8 + 1 = 249 zeros. Each factor of 5 paired with a factor of 2 creates one trailing zero; factors of 2 always outnumber factors of 5.
What real-world applications use factorials?
Factorials appear in: Probability (binomial and Poisson distributions), Statistical mechanics (Boltzmann entropy formula uses N! for particle microstates), Computer science (the Travelling Salesman Problem for n=20 cities has 19! ≈ 1.2 × 10^17 routes), Genomics (counting possible gene orderings), and Cryptography (permutation cipher key spaces — for a 256-element permutation, 256! ≈ 8.58 × 10^506).