How to Use the Factorial Calculator
This factorial calculator computes n! instantly for any non-negative integer n. To also compute permutations (nPr) and combinations (nCr), enter the value of r as well. Results for n > 20 are shown in scientific notation since exact values exceed JavaScript's safe integer range. The calculator also shows Stirling's approximation for n ≥ 10 to illustrate the growth pattern.
For example, enter n = 52 to find the number of possible orderings of a standard deck of cards: 52! ≈ 8.07 × 10⁶⁷. This number is so large that if every human who ever lived had been shuffling 1000 decks per second since the Big Bang, they would not have exhausted all orderings. For related topics, see our proportion calculator.
Factorial Formula and Properties
The factorial function is defined recursively:
- 0! = 1 (by definition)
- n! = n × (n − 1)! for n ≥ 1
Key factorials to know: 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, 10! = 3,628,800, 20! ≈ 2.43 × 10¹⁸, 100! ≈ 9.33 × 10¹⁵⁷.
Permutations — nPr
The number of ordered arrangements of r items chosen from n distinct items:
nPr = n! / (n − r)!
Example: How many ways can you arrange 3 books from a shelf of 8? P(8,3) = 8! / 5! = 8 × 7 × 6 = 336 ordered arrangements.
Combinations — nCr
The number of unordered selections of r items from n distinct items (order does not matter):
nCr = n! / (r! × (n − r)!)
Example: How many ways can you choose a committee of 3 from 8 people? C(8,3) = 8! / (3! × 5!) = 56. This is the binomial coefficient, fundamental to probability and Pascal's triangle.
Stirling's Approximation
For large n, computing n! by multiplying every integer from 1 to n is impractical. Stirling's approximation provides an excellent estimate:
n! ≈ √(2πn) × (n/e)ⁿ
Where e = 2.71828... (Euler's number). The approximation becomes more accurate as n grows — the relative error is about 1/(12n), meaning less than 1% error for n > 8. Stirling's formula is essential in statistical mechanics (calculating entropy), information theory, and asymptotic analysis of algorithms.
Real-World Applications of Factorials
- Card games — a 52-card deck has 52! ≈ 8 × 10⁶⁷ possible orderings; every shuffle is almost certainly unique in history
- Probability — the denominator of many probability formulas involves factorials through combinations
- Taylor series — the expansion of eˣ = Σ(xⁿ/n!) uses factorials in every term
- Combinatorics — counting passwords, PINs, combinations of ingredients in recipes
- Statistics — the binomial distribution P(X=k) = C(n,k) × pᵏ × (1−p)^(n−k) uses combinations
For calculations involving large numbers in other formats, our decimal calculator handles precision arithmetic.
Common Factorial Values Table
- 0! = 1
- 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
- 15! = 1,307,674,368,000
- 20! ≈ 2.43 × 10¹⁸
- 50! ≈ 3.04 × 10⁶⁴
- 100! ≈ 9.33 × 10¹⁵⁷
Sources & References
- Factorial — Wikipedia
- Permutation — Wikipedia
- Combination — Wikipedia
- Stirling's approximation — Wikipedia