Factorial is one of those mathematical operations where the numbers get enormous extraordinarily fast — 20! = 2,432,902,008,176,640,000, a number with 19 digits, computed from multiplying just the integers 1 through 20. This explosive growth makes factorials foundational to combinatorics, probability, and statistics, where they count arrangements and selections of objects. But the rapid growth also creates practical calculation challenges, and understanding how to work with factorials — including the Stirling approximation for large values, the relationship to the gamma function, and how to simplify factorial expressions before multiplying — keeps the math tractable.
Applications in Permutations, Combinations, and Probability
Rachel, 27, in Boston, Massachusetts is hosting a dinner party for 8 guests and wants to arrange seating. How many different arrangements of 8 people in 8 seats exist? 8! = 40,320 distinct arrangements. If the table is circular (only relative order matters, not which specific seat), divide by the number of rotations: (8-1)! = 7! = 5,040 distinct circular arrangements.
Five-card poker hands from a 52-card deck: C(52,5) = 52!/(5! × 47!) = 2,598,960 total hands. Of these, how many are full houses (3 of one rank + 2 of another)? Choose the rank for the triplet: C(13,1) = 13. Choose 3 suits from 4 for the triplet: C(4,3) = 4. Choose the rank for the pair: C(12,1) = 12. Choose 2 suits from 4 for the pair: C(4,2) = 6. Total full houses: 13 × 4 × 12 × 6 = 3,744. Probability: 3,744/2,598,960 = 0.00144 ≈ 1 in 694 hands. Every step of this calculation uses the factorial-based combination formula, making factorials the foundation of poker probability and combinatorics generally.
The Basic Definition
n! (n factorial) = n × (n-1) × (n-2) × ... × 2 × 1. By convention, 0! = 1 (this is mathematically consistent and necessary for the combinatorics formulas to work at boundary cases). 1! = 1. 2! = 2. 3! = 6. 4! = 24. 5! = 120. 6! = 720. 7! = 5,040. 10! = 3,628,800. 15! = 1,307,674,368,000. 20! = 2,432,902,008,176,640,000.
The recursive definition: n! = n × (n-1)! for n > 0. So 5! = 5 × 4! = 5 × 24 = 120. This recursive structure makes factorials natural to compute in programming and to simplify in algebra.
Trailing Zeros in n!
A common mathematical puzzle: how many trailing zeros does 100! have? Trailing zeros come from factors of 10 = 2 × 5. Since factors of 2 are always more abundant than factors of 5 in factorials, the number of trailing zeros = number of times 5 appears as a factor in 1 through 100. Count multiples of 5: 100÷5 = 20. Multiples of 25 (contributing an extra 5 each): 100÷25 = 4. Multiples of 125: 100÷125 = 0. Total: 20 + 4 = 24 trailing zeros in 100!.
This is Legendre's formula: the exponent of prime p in n! equals floor(n/p) + floor(n/p²) + floor(n/p³) + ... (sum until terms go to zero). Applied to count 5s in 50!: floor(50/5) + floor(50/25) = 10 + 2 = 12 trailing zeros in 50!.
Related Calculators
Simplifying Factorial Expressions
Most combinatorics problems involve ratios of factorials, and careful simplification before multiplying is essential. n! / (n-k)! means n × (n-1) × ... × (n-k+1) — just k terms, not the full factorial computation. P(10,3) = 10!/7! = 10 × 9 × 8 = 720. You don't need to compute 10! = 3,628,800 and 7! = 5,040 and then divide — you recognize that all terms from 7 down to 1 cancel.
Similarly, n! / (n-k)! / k! = C(n,k). C(52,5) = 52! / 5! / 47! = (52 × 51 × 50 × 49 × 48) / (5 × 4 × 3 × 2 × 1) = 311,875,200 / 120 = 2,598,960. Computing the five-term numerator product rather than the full 52-factorial saves enormous calculation effort.
The Gamma Function: Extending Factorials
The factorial function is defined only for non-negative integers. The gamma function Γ(n) extends it to real and complex numbers. For positive integers: Γ(n) = (n-1)!. So Γ(5) = 4! = 24. For non-integer values: Γ(1/2) = √π ≈ 1.7725. This allows computing (1/2)! = Γ(3/2) = (1/2) × Γ(1/2) = √π/2 ≈ 0.8862.
The gamma function appears in statistics, particularly in the gamma and beta distributions, and in the formula for the volume of n-dimensional balls. The volume of an n-dimensional ball of radius r is V = π^(n/2) × r^n / Γ(n/2 + 1) — factorials (via gamma) determine how volume behaves as dimensions increase.
Stirling's Approximation for Large Factorials
When n is large, exact factorial computation exceeds the range of standard floating-point numbers. Stirling's approximation provides excellent estimates: n! ≈ √(2πn) × (n/e)^n. For n=100: √(2π×100) × (100/e)^100 ≈ 25.066 × (36.788)^100. Taking logarithm: log₁₀(100!) ≈ (1/2)log₁₀(200π) + 100×log₁₀(100/e) = 1.1997 + 100×1.5703 = 1.1997 + 157.03 = 158.23. So 100! ≈ 10^158.23 — a 158-digit number. The exact value is 9.33 × 10^157. Stirling's approximation is accurate to within 1% for n ≥ 10 and gets more accurate as n grows.