Factorial Calculator
100 factorial is 9.3326 x 10^157, a number with 158 digits that ends in 24 zeros. The full value starts 93326215443944152681 and stops being displayable on most calculators long before n reaches 100.
Enter a whole number from 0 to 1000 and the calculator returns the factorial exactly, digit by digit, plus the digit count, trailing zeros and a Stirling estimate. Add k to get permutations and combinations. Everything runs in your browser.
| n factorial | |
| Number of digits | |
| Trailing zeros | |
| log10 of n factorial | |
| Scientific form | |
| Fits in a double, a finite value | |
| Exact in a double, every digit kept | |
| Stirling estimate | |
| Stirling error | |
| Permutations P(n, k) | |
| Combinations C(n, k) |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter a whole number and the calculator returns its factorial exact to the last digit, with the digit count, trailing zeros, a Stirling estimate and the matching permutations and combinations.
Key takeaways
- n! multiplies every whole number from 1 to n, and 0! is 1 by the empty product rule
- 100! has 158 digits and 24 trailing zeros, and 52! has 68 digits and 12 zeros
- 170! is the largest factorial a double holds, and 23! is the first one that loses digits
- Trailing zeros come from factors of 5: floor(n/5) + floor(n/25) + floor(n/125) and so on
On this page
What a factorial counts
The factorial of a whole number is the product of every whole number from 1 up to it: n! = n x (n - 1) x (n - 2) x ... x 1. Five books on a shelf can be arranged in 5! orders, which is 5 x 4 x 3 x 2 x 1 = 120, and that counting interpretation is where the function earns its keep in probability and combinatorics.
Zero factorial is 1 by convention, and the convention has a reason: there is exactly one way to arrange an empty shelf. The NIST Digital Library of Mathematical Functions, section 5.4 records the same value through the gamma function, where n! is gamma(n + 1) and gamma(1) is 1.
Factorials grow faster than any exponential. Double the input and you square roughly the answer: 10! is 3,628,800 and 20! is 2,432,902,008,176,640,000. That growth is why the numbers run out of calculator display so early and why this page uses exact integer arithmetic instead of floating point.
The factorials people look up
Most searches land on a handful of values, so the table below keeps them in one place with the digit count and the trailing zeros attached.
| n | n factorial | Digits | Trailing zeros |
|---|---|---|---|
| 5 | 120 | 3 | 1 |
| 10 | 3,628,800 | 7 | 2 |
| 20 | 2,432,902,008,176,640,000 | 19 | 4 |
| 25 | 15,511,210,043,330,985,984,000,000 | 26 | 6 |
| 52 | 806,581,751,709 ... 000,000 (8.0658e+67) | 68 | 12 |
| 100 | 933,262,154,439 ... 000,000 (9.3326e+157) | 158 | 24 |
The 52 entry is the card deck: 52! is 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000, a 68 digit number, and it is the standard answer to how many ways a deck can be shuffled. The 100 entry is the usual test case for a program, because 100! overflows almost every fixed width type and still fits inside a decent big integer library.
Notice the trailing zeros in the last column. They are not decoration: 100! ends in 24 zeros, which means the last 24 digits of the full number are zeros and only the first 134 digits carry information.
Where double precision stops
A standard double holds values up to about 1.7977 e308, and 170! is 7.2574 e306, so 170 is the last factorial that fits. Multiply by 171 and the result is 1.2410 e309, which overflows to Infinity. That is the exact point where a scientific calculator shows an error and a spreadsheet returns a number that looks broken.
Fitting is one question and accuracy is another. A double carries 53 bits of mantissa, about 15 to 17 significant decimal digits, and 22! is 1.1240 e21, which still stores exactly. At 23! the value needs more bits than the mantissa has, so the last digits are already wrong. Every factorial from 23 up is approximate in floating point, and the error stays hidden because the first digits look right.
This calculator keeps the exact integer, so 100! arrives with all 158 digits in place, and the page reports both whether the value fits and whether a double could store it exactly.
The practical rule for code is short. Below 23 the two agree and either type works. Between 23 and 170 a double gives you the magnitude and the first fifteen digits, which is fine for a probability that gets multiplied by something tiny. Past 170 a double gives you nothing but Infinity, so the choice is a big integer library or a logarithm of the value.
Trailing zeros and digit counts without multiplying
You can get the zeros and the length without computing the number. Trailing zeros come from factors of 10, and every factor of 10 needs a 2 and a 5. Factors of 2 are everywhere in a factorial, so the count is set by the factors of 5: z(n) = floor(n / 5) + floor(n / 25) + floor(n / 125) and so on, one term for each power of 5 below n.
For 100: floor(100 / 5) = 20 and floor(100 / 25) = 4, so 20 + 4 = 24 zeros. For 1000: 200 + 40 + 8 + 1 = 249 zeros. The digit count follows from log10: digits = floor(log10(n!)) + 1, and since log10(100!) is 157.97, 100! has 158 digits.
| n | Trailing zeros | Digits in n factorial | Zeros as a share of digits |
|---|---|---|---|
| 10 | 2 | 7 | 28.6 percent |
| 25 | 6 | 26 | 23.1 percent |
| 50 | 12 | 65 | 18.5 percent |
| 100 | 24 | 158 | 15.2 percent |
| 250 | 62 | 493 | 12.6 percent |
| 500 | 124 | 1,135 | 10.9 percent |
| 1,000 | 249 | 2,568 | 9.7 percent |
Those two formulas are worth memorizing because they turn a question that looks like heavy arithmetic into a few divisions. The zeros of 999! come from floor(999/5) + floor(999/25) + floor(999/125) + floor(999/625), which is 199 + 39 + 7 + 1 = 246, and no multiplication is involved anywhere in that line.
The share column is the useful one for a sanity check. Zeros hover near 4 percent of the digits, because each power of 5 contributes one zero while each power of 10 adds a digit. A claim that 1000! ends in 500 zeros would imply a much larger share than that and is easy to reject without touching a calculator.
Stirling's approximation and how far off it is
Stirling's formula estimates a factorial without multiplying anything: n! is close to sqrt(2 pi n) x (n / e)^n. The estimate is always a little low, and the relative error is roughly 1 / (12n), so it improves as n grows.
| n | Exact n factorial | Stirling estimate | Error |
|---|---|---|---|
| 5 | 1.200000e+02 | 1.180192e+02 | -1.65 percent |
| 10 | 3.628800e+06 | 3.598696e+06 | -0.83 percent |
| 20 | 2.432902e+18 | 2.422787e+18 | -0.42 percent |
| 52 | 8.065818e+67 | 8.052902e+67 | -0.16 percent |
| 100 | 9.332622e+157 | 9.324848e+157 | -0.08 percent |
At 5! the estimate is 1.65 percent low, which is visible. At 100! it is 0.0833 percent low, and 1 / (12 x 100) predicts exactly that. The pattern is why Stokes and statistical mechanics use the approximation freely: for the sizes those fields handle, the error is far below any measurement.
The estimate is also the only practical way to handle a factorial inside a floating point formula, because it stays finite far past 170. This page shows it next to the exact value so you can see the gap rather than take it on faith.
Permutations and combinations from one factorial
Two counting formulas sit on top of the factorial. A permutation counts ordered picks: P(n, k) = n! / (n - k)!. A combination counts unordered picks: C(n, k) = n! / (k! x (n - k)!). OpenStax Precalculus, section 11.5 builds both from the multiplication principle, and both are exact integer divisions, which is why the calculator can return them from the same big integer it already built.
Five cards from a 52 card deck: the ordered count is 52 x 51 x 50 x 49 x 48 = 311,875,200, and dividing by 5! = 120 leaves 2,598,960 distinct hands. A 6 of 49 lottery is smaller, at 13,983,816 possible tickets, and that number is the reason the odds of a jackpot are quoted in the millions rather than the billions.
Enter k next to n in the calculator and both values appear. Permutations are always at least as large as combinations for the same pair, since every unordered pick can be arranged in k! orders, and that ratio is a quick way to catch a swapped formula.
Mistakes and edge cases
Most wrong factorial answers come from a short list of habits rather than from the multiplication itself.
| Mistake | What comes out | Correct answer |
|---|---|---|
| Treating 0! as 0 | 0 | 1, because there is one way to arrange nothing |
| Asking for the factorial of a negative number | Some calculators return an error | Undefined, the gamma function has poles at 0 and every negative integer |
| Reading 5! as 5 x 5 | 25 | 120, from 5 x 4 x 3 x 2 x 1 |
| Guessing 10! as 10 x 9 | 90 | 3,628,800 |
| Using double precision past 170 | Infinity | 171! is 1.2410 e309, and the exact digits are available |
| Trusting a double at 23! | The last digits are wrong | 23! needs more than 53 significant bits |
The overflow row is the one that surprises people in practice, because the failure is silent in some tools. A spreadsheet that returns 9.9999 e307 style garbage for 171! looks like a number, and only a check against the known value shows the problem.
Fractional inputs are a separate matter. Half of a factorial is not defined by the product rule at all, and the value people quote for 0.5 comes from the gamma function, which is a different tool. This page stays with whole numbers from 0 to 1000 and says so rather than guessing at a decimal answer.
Frequently asked questions
What is 10 factorial?
3,628,800. The product is 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1, and the number has 7 digits with 2 trailing zeros.
What is 0 factorial and why is it 1?
0! is 1 because there is exactly one way to arrange nothing, and because the recursion (n + 1)! = (n + 1) x n! only stays consistent at n = 0 if 0! is 1.
What is 100 factorial?
9.3326 e157, a 158 digit number that ends in 24 zeros. The first digits are 93326215443944152681 and the last non-zero part sits 24 places from the end.
What is 52 factorial?
A 68 digit number, about 8.0658 e67, which is the count of possible orderings of a standard deck. Its trailing 12 zeros come from the factors of 5 between 1 and 52.
Is there a factorial of a negative number?
No, not in the ordinary sense. The gamma function, which extends the factorial, has poles at 0 and at every negative integer, so the value is undefined there.
What is 5 factorial?
120, from 5 x 4 x 3 x 2 x 1. It has 3 digits and 1 trailing zero.
How many trailing zeros does 100 factorial have?
24. floor(100 / 5) = 20 and floor(100 / 25) = 4, and higher powers of 5 add nothing, so 20 + 4 = 24.
What is the largest factorial a double can hold?
170! at 7.2574 e306. The double maximum is about 1.7977 e308, and 171! is 1.2410 e309, which overflows to Infinity.
What is 20 factorial?
2,432,902,008,176,640,000, a 19 digit number with 4 trailing zeros. It is still stored exactly in a double.
When does a double stop being exact for factorials?
At 23!. Up to 22! every digit stores exactly, and 23! needs more than the 53 bits of mantissa a double provides.
What is the difference between a factorial and a permutation?
n! counts the orderings of all n items, while P(n, k) = n! / (n - k)! counts ordered picks of k items. For 52 cards and 5 picks, P is 311,875,200.
How many 5 card hands are there in a 52 card deck?
2,598,960. That is C(52, 5), which is 311,875,200 divided by 5! = 120, since the order of a hand does not matter.
What is 1 factorial?
1. The product holds a single term, so the value is 1, the same as 0!.
How accurate is Stirling's approximation?
The relative error is about 1 / (12n). At n = 100 the estimate 9.3248 e157 is 0.0833 percent below the exact 9.3326 e157, and at n = 5 the gap is 1.65 percent.
How many digits does 1000 factorial have?
2,568 digits, and it ends in 249 zeros. The zeros come from 200 + 40 + 8 + 1 factors of 5 across the powers of 5 below 1,000.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.