Exact n! for whole numbers 0–1,000, with steps and trailing zeros.
By O.E. — Partner, chairman of the board and CEO of a metal products manufacturer for 21 years; the company exports to 45 countries.
Drafted with AI assistance; calculations checked against primary sources and tested with the site's own code. About FlowUtil
Last reviewed
n! = n × (n − 1) × … × 2 × 1, with 0! = 1 and 1! = 1; equivalently n! = n × (n − 1)!, so 10! = 10 × 362,880 = 3,628,800.
Trailing zeros: every trailing zero comes from a factor 10 = 2 × 5, and a factorial always has more factors of 2 than of 5, so the number of zeros equals the number of 5s in its prime factorization — one for each multiple of 5, one more for each multiple of 25, another for each multiple of 125, and so on: ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … (Legendre's formula for the prime 5).
Why 0! = 1: there is exactly one way to arrange zero objects, and n! = n × (n − 1)! gives 1! = 1 × 0!, which only works if 0! = 1. The same value makes the combination formula C(n, 0) = 1 correct.
Exact arithmetic: ordinary calculator arithmetic (64-bit floating point) keeps only about 16 significant digits, so from 23! on it cannot hold the exact value. This calculator multiplies whole numbers of unlimited length, so every digit of 1000! (2,568 digits) is correct. The digit count and a short scientific form (for example 9.3326 × 10^157 for 100!) are shown next to the full value.
| Symbol | Meaning |
|---|---|
| n | A whole number from 0 to 1,000 |
| n! | Product of all whole numbers from 1 to n |
| Γ(n + 1) | Gamma function; equals n! for whole numbers and extends it to non-integers |
1Arranging people: in how many orders can 8 people stand in a line?
8! = 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1
8! = 40,320 · Trailing zeros: ⌊8/5⌋ = 1
40,320 different orders — and it ends in exactly one zero.
2Trailing zeros of 25!.
⌊25/5⌋ + ⌊25/25⌋ = 5 + 1
25! = 15,511,210,043,330,985,984,000,000 (26 digits) · Trailing zeros: 6
Note the jump: 24! has 4 trailing zeros, 25! has 6, because 25 = 5 × 5 contributes two factors of 5.
3Shuffling a deck of cards: 52!.
52! = 52 × 51 × … × 1; zeros ⌊52/5⌋ + ⌊52/25⌋ = 10 + 2
52! ≈ 8.0658 × 10^67 (68 digits) · Trailing zeros: 12
Every thorough shuffle almost certainly produces an order of the deck that has never existed before.
Most practical uses of factorials are ratios, which are far smaller than the factorials themselves. Cancel before multiplying: 10! ÷ 7! = 10 × 9 × 8 = 720 without computing either factorial in full.
| Question | Formula | Example |
|---|---|---|
| Orders of all n items | n! | 8 runners finish in 8! = 40,320 possible orders |
| Ordered picks of r from n (permutations) | P(n, r) = n! ÷ (n − r)! | Gold, silver, bronze among 10 runners: 10! ÷ 7! = 720 |
| Unordered picks of r from n (combinations) | C(n, r) = n! ÷ (r! × (n − r)!) | 5-card poker hands: 52! ÷ (5! × 47!) = 2,598,960 |
Digit count grows faster than n: 10! has 7 digits, 20! has 19, 52! has 68, 100! has 158, 170! has 307 and 1000! has 2,568.
The trailing-zero count comes straight from the formula above, not from scanning the digits — useful in number puzzles and programming exercises.