By Tim King · Updated
Factorial Calculator
Exact Factorials Up to 5,000 in Scientific Notation, With Digit Count and Trailing Zeros
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the Factorial Calculator works
This factorial calculator works out n! exactly for any whole number from 0 to 5,000, using big integers so no digit is lost. Alongside the result it gives scientific notation, the total number of digits and the number of trailing zeros. For small n it writes the product out, such as 5! = 5 × 4 × 3 × 2 × 1.
A factorial multiplies a whole number by every whole number below it down to 1. It counts the ways to arrange things in order: 3 books on a shelf can go in 3! = 6 orders, and a shuffled deck of 52 cards has 52! arrangements, a 68-digit number. Factorials sit at the heart of permutations, combinations and probability, and they grow faster than any power.
How the factorial calculator works
The formula is n! = n × (n − 1) × … × 2 × 1, with 0! = 1 by definition. The calculator multiplies exactly with big integers. Trailing zeros come from pairs of 2 and 5 among the factors, and since 2s are plentiful, the count is n/5 + n/25 + n/125 + …, rounding each term down. This is Legendre's formula.
First example. 10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800.
Second example. 100! has 158 digits and 24 trailing zeros, since 100/5 + 100/25 = 20 + 4 = 24.
How many ways can 8 people sit in a row? 8! = 40,320 different orders.
Factorials from 0! to 25!
| n | n! | Digits | Trailing zeros |
|---|---|---|---|
| 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 0 |
| 2 | 2 | 1 | 0 |
| 3 | 6 | 1 | 0 |
| 4 | 24 | 2 | 0 |
| 5 | 120 | 3 | 1 |
| 6 | 720 | 3 | 1 |
| 7 | 5,040 | 4 | 1 |
| 8 | 40,320 | 5 | 1 |
| 9 | 362,880 | 6 | 1 |
| 10 | 3,628,800 | 7 | 2 |
| 11 | 39,916,800 | 8 | 2 |
| 12 | 479,001,600 | 9 | 2 |
| 13 | 6,227,020,800 | 10 | 2 |
| 14 | 87,178,291,200 | 11 | 2 |
| 15 | 1,307,674,368,000 | 13 | 3 |
| 16 | 20,922,789,888,000 | 14 | 3 |
| 17 | 355,687,428,096,000 | 15 | 3 |
| 18 | 6,402,373,705,728,000 | 16 | 3 |
| 19 | 121,645,100,408,832,000 | 18 | 3 |
| 20 | 2,432,902,008,176,640,000 | 19 | 4 |
| 21 | 51,090,942,171,709,440,000 | 20 | 4 |
| 22 | 1,124,000,727,777,607,680,000 | 22 | 4 |
| 23 | 25,852,016,738,884,976,640,000 | 23 | 4 |
| 24 | 620,448,401,733,239,439,360,000 | 24 | 4 |
| 25 | 15,511,210,043,330,985,984,000,000 | 26 | 6 |
Tips and pitfalls
- 0! is 1. There is exactly one way to arrange nothing, and it keeps the nCr formula working.
- Negatives have no factorial. The gamma function extends it to decimals, but not to negative whole numbers.
- Cancel before multiplying. 10! ÷ 8! is just 10 × 9 = 90, no need for the full numbers.
- Spreadsheets overflow. Excel's FACT stops at 170!; this calculator stays exact to 5000!.
FAQ
What is a factorial?
A factorial, written n!, is the product of all whole numbers from 1 to n. So 4! = 4 × 3 × 2 × 1 = 24 and 6! = 720. It counts the orders in which n different things can be arranged, which is why it appears in so many counting and probability questions.
Why is 0 factorial equal to 1?
There is exactly one way to arrange zero objects: do nothing. It also keeps the pattern consistent, because n! = (n + 1)! ÷ (n + 1), so 0! = 1! ÷ 1 = 1. Without it, the formula for combinations would break whenever you choose all or none of the items.
How many digits are in 100 factorial?
100! has 158 digits and ends with 24 zeros. It starts 93,326,215,443,944 and is roughly 9.33 × 10^157. Enter 100 in the calculator to see its leading and trailing digits, digit count and the trailing zeros worked out from Legendre's formula.
How do you count the trailing zeros in a factorial?
Count the factors of 5, because each pairs with a 2 to make a 10. Divide n by 5, then by 25, then by 125, and add the whole-number parts. For 50!, that is 10 + 2 = 12 trailing zeros. The calculator shows this count for every n.
What is the largest factorial a calculator can show?
Most calculators and spreadsheets stop at 170!, about 7.26 × 10^306, because 171! is beyond the largest double-precision number. This calculator uses exact integer arithmetic and goes up to 5000!, a number with 16,326 digits.
See also: all Number Theory tools, Arithmetic, Algebra and Geometry, Statistics, Trigonometry and Calculus.
Related tools
Permutation And Combination Calculator
nCr and nPr, with and without repetition, exact to the last digit.
Exponent Calculator
Raise a number to any power, with exact results for big powers.
Probability Calculator
Combine two probabilities, and the odds of at least once.
Prime Number Checker
Check if a number is prime, or list the primes in a range.
Factor Calculator
All the factors, factor pairs and prime factorisation of a number.