What a factorial is
The factorial of a whole number n, written n!, is the product of every whole number from n down to 1.
It counts the ways to arrange n different things in a row. Three books can be lined up in 3! = 3 × 2 × 1 = 6 ways.
Worked examples
- 5! = 5 × 4 × 3 × 2 × 1 = 120.
- 10! = 10 × 9! = 10 × 362,880 = 3,628,800.
- 52! ≈ 8.065817517 × 10⁶⁷. That's how many orders a shuffled deck of cards can be in, a 68-digit number.
- 100! has 158 digits and ends in 24 zeros.
Counting the trailing zeros
Each trailing zero comes from a factor of 10, which is 2 × 5. There are always more 2s than 5s, so count the 5s: add n ÷ 5, n ÷ 25, n ÷ 125 and so on, dropping the remainders. For 100!, that's 20 + 4 = 24 zeros.
Why ordinary calculators give up
Factorials grow faster than powers. Most calculators store numbers in a format that tops out near 10³⁰⁸, so they show an error after 170! (about 7.257415615 × 10³⁰⁶). Many handheld calculators stop at 69!, because 70! is larger than 10¹⁰⁰. This calculator multiplies with exact whole-number arithmetic (JavaScript BigInt), so every digit is right. It stops at 5,000 to keep the page fast; 5,000! has 16,326 digits.
Fractions and negative numbers
n! is only defined for whole numbers 0 and up. The gamma function extends it to other numbers, with Γ(n + 1) = n! for whole n. For example, Γ(1.5) = √π ÷ 2 ≈ 0.886227 is sometimes written "0.5!". Gamma has no value at 0, −1, −2 and so on, so there's no factorial of a negative whole number. If you type a non-whole number, the calculator shows the gamma value instead.