Factorial Calculator
Calculate n! exactly for any whole number from 0 to 5,000, with every digit. You also get the digit count, trailing zeros, the double factorial n!! and a nearby-factorials table.
Whole number from 0 to 5,000
How to use the Factorial Calculator
- Enter a whole number n from 0 to 5,000, or tap an example.
- Press Calculate factorial (results also update as you type).
- Read n!, its digit count, trailing zeros and n!!.
- Scroll the exact value box for every digit, or press Copy results to copy them all.
Factorial formulas
- Factorial: n! = n × (n − 1) × (n − 2) × … × 2 × 1, with 0! = 1
- Recursive rule: n! = n × (n − 1)!
- Double factorial: n!! = n × (n − 2) × (n − 4) × … ending at 1 (odd n) or 2 (even n)
- Trailing zeros (Legendre): Z(n) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
- Number of digits: ⌊log₁₀ 1 + log₁₀ 2 + … + log₁₀ n⌋ + 1
- Stirling's approximation: n! ≈ √(2πn) · (n / e)n
Factorial table 0! to 20!
| n | n! | n | n! |
|---|---|---|---|
| 0 | 1 | 11 | 39,916,800 |
| 1 | 1 | 12 | 479,001,600 |
| 2 | 2 | 13 | 6,227,020,800 |
| 3 | 6 | 14 | 87,178,291,200 |
| 4 | 24 | 15 | 1,307,674,368,000 |
| 5 | 120 | 16 | 20,922,789,888,000 |
| 6 | 720 | 17 | 355,687,428,096,000 |
| 7 | 5,040 | 18 | 6,402,373,705,728,000 |
| 8 | 40,320 | 19 | 121,645,100,408,832,000 |
| 9 | 362,880 | 20 | 2,432,902,008,176,640,000 |
| 10 | 3,628,800 | 21 | 51,090,942,171,709,440,000 |
21! is the first factorial that no longer fits in a 64-bit integer, and 171! overflows ordinary double-precision floating point. That is why this calculator uses exact big-integer arithmetic.
Frequently asked questions
What is a factorial?
n! (n factorial) is the product of all whole numbers from 1 to n. For example 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the number of ways to arrange n different items in a row.
Why is 0! equal to 1?
There is exactly one way to arrange zero items (do nothing), and the rule n! = n × (n − 1)! only works for n = 1 if 0! = 1. It also keeps formulas such as nCr = n! ÷ (r!(n − r)!) correct.
How many trailing zeros does 100! have?
24. Each trailing zero comes from a factor 10 = 2 × 5, and there are fewer 5s than 2s, so count the 5s: ⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24 (Legendre's formula).
How many digits does 100! have?
100! has 158 digits. In general the digit count is ⌊log₁₀(n!)⌋ + 1, which you can find by adding log₁₀ of every number from 1 to n.
What is a double factorial?
n!! multiplies every second number down from n: 7!! = 7 × 5 × 3 × 1 = 105 and 8!! = 8 × 6 × 4 × 2 = 384. It is not the same as (n!)!.
Can you take the factorial of a negative number or a decimal?
Not with the ordinary definition, which only covers whole numbers 0, 1, 2 and so on. The gamma function extends it to decimals (Γ(n + 1) = n!), but it is undefined at negative integers.
What is 52 factorial?
52! ≈ 8.0658 × 10^67, a 68-digit number. It is the number of ways to shuffle a standard deck of 52 cards, so a well-shuffled deck is almost certainly in an order that has never existed before.