Factorial Calculator (n!)

THE FACTORIAL
Type a whole number and press the equals key.
The product, the zeros, and the check
Your number
Whole numbers only, from 0 upwards. Commas and spaces are read, so 1,000 and 1 000 both work, and a trailing ! is ignored if you type one. AC empties the box and holding deletes one digit after another.
The answer is n multiplied by every whole number below it, down to 1. By definition 0! = 1.
Tap a box, then use the keys
Factorials grow faster than almost anything else you will meet: 20! already passes two quintillion, and 1000! runs to 2,568 digits. The band also gives the digit count and the number of zeros on the end — both worked out from n alone, so they still arrive when the number itself is far too long to print.
How the factorial is worked out

This factorial calculator works out n! — every whole number from n down to 1, multiplied together — and prints it exactly, however long it turns out to be.

5! = 5 × 4 × 3 × 2 × 1 = 120. Simple enough. Then 20! is 2,432,902,008,176,640,000, and 100! is a number with 158 digits, and somewhere in between your phone gave up and started rounding.

Where an Ordinary Calculator Stops

The cut-off is sharper than most people expect, and it is worth knowing exactly where it falls.

20! is 2,432,902,008,176,640,000, and a computer holds that exactly. So does 21!, and so, just, does 22!. What fails first is not the storage but the printing: the true 22! ends 7,680,000, while the figure a machine shows you ends 7,700,000. At 23! the stored value is itself wrong, and at 171! there is nothing left to store — the arithmetic overflows and hands back infinity. A pocket calculator gives up long before any of that, switching to something like 5.109e+19 the moment its ten-digit window fills.

For an estimate that is fine. For a homework answer, a proof, or a counting argument you intend to check, it is useless. This page holds whole numbers from start to finish, so 100! comes back with all 158 of its digits and 1000! with all 2,568.

The Zeros on the End, Counted Without the Number

Here is the part that surprises people. You can say exactly how many zeros 1000! ends in without ever working out 1000!.

A zero on the end means a factor of ten, and ten is two times five. In a factorial there are twos everywhere and fives are comparatively rare, so the fives run out first and it is the fives that decide the count. How many factors of five are hiding in 1000!? Every fifth number contributes one, every twenty-fifth contributes another, and so on:

⌊1000÷5⌋ + ⌊1000÷25⌋ + ⌊1000÷125⌋ + ⌊1000÷625⌋ = 200 + 40 + 8 + 1 = 249

So 1000! ends in 249 zeros. Adrien-Marie Legendre published this in 1808, and it remains the reason a web page can answer the question in a millisecond while a naive program is still multiplying.

100! works out to 20 + 4 = 24 zeros, which is the version that turns up in exams.

The Same Trick Gives the Highest Power of Any Prime

Swap the five for a three and you have answered a different exam favourite: what is the largest power of 3 that divides 100!?

Add the whole-number parts of 100÷3, 100÷9, 100÷27 and 100÷81. That is 33 + 11 + 3 + 1 = 48, so 348 divides 100! and 349 does not.

The working panel on this page prints those exponents for the small primes as a matter of course, which means the answer is already on screen rather than something you have to set up. I have not found another factorial tool that does it, and the question is common enough that the omission is odd.

Why 0! Is 1

This is the single most queried fact about factorials, and the usual answer — "it is defined that way" — is true and unsatisfying.

Two better reasons. First, counting: n! counts the arrangements of n things, and there is exactly one way to arrange nothing, namely to do nothing. Doing nothing is a thing you can do, and there is only one of it.

Second, the recurrence. Every factorial obeys n! = n × (n − 1)!. Put n = 1 and it says 1! = 1 × 0!. Since 1! is 1, the value of 0! has no choice but to be 1 as well. Define it differently and that relationship breaks at the very first step, taking the counting formulas that rely on it down with it.

NumberIts factorialDigits
0 and 111
103,628,8007
202,432,902,008,176,640,00019
100ends in 24 zeros158
1,000ends in 249 zeros2,568
1,000,000ends in 249,998 zeros5,565,709

What Happens Past the Point of Printing

A million factorial has 5,565,709 digits. Set in nine-point type it would fill a few thousand pages, and reading it would tell you nothing at all.

So this page stops printing the value somewhere above ten thousand — and keeps answering. The digit count, the trailing zeros and the prime exponents all come from n directly rather than from the number, so they survive long after the value itself has become useless. Type 1000000 and you will get 5,565,709 digits and 249,998 zeros, both exact, in about the time it takes to press the key.

The Two Inputs This Page Turns Down

Negatives have no factorial, and not in the sense that nobody has worked one out. Run n! = n × (n − 1)! downwards and at zero it demands a division by zero. There is nothing to return.

Fractions are a more interesting refusal. There genuinely is a smooth curve passing through all the factorial values, called the gamma function, and 4.5 sits on it at roughly 52.34. But that is a different function with a different formula, and handing back its value under a factorial sign would be quietly misleading. The page says what the object is called and leaves you to go and look at it properly.

Where Factorials Actually Get Used

Almost nobody needs a bare factorial. What they need is a factorial inside something else.

Arrangements of r items from n come out as n! divided by (n − r)!, which the permutation calculator handles; divide that by r! as well and you have the selection count on the combination calculator. Both of those pages cancel the factorials against each other rather than building them, which is the only sane way to do it once n passes a few hundred. Factorials also run through Taylor series, through probability, and through most of the counting arguments you meet after school.

How to Use This Factorial Calculator

Type the number and press =. A trailing exclamation mark is ignored if you write one, and commas are read, so 1,000 and 1000 behave the same. AC empties the box; holding deletes digit after digit.

Show the working opens the product, the digit count, Legendre's sum written out term by term, the prime exponents and the last non-zero digit. Before any of it appears the result is put back through the mathematics: n! is rebuilt as n × (n − 1)!, the predicted zero count is compared against the zeros actually sitting on the end of the number, and for smaller n the prime factorisation is multiplied back out to see whether it returns what it started from. The number of checks that passed is printed with the working.

Factorial Calculator FAQ

What is a factorial?
The factorial of a whole number n, written n!, is every whole number from n down to 1 multiplied together. So 5! = 5 × 4 × 3 × 2 × 1 = 120.
Why is 0! equal to 1?
There is exactly one way to arrange nothing, which is to do nothing. The recurrence n! = n × (n−1)! also forces it: put n = 1 and you get 1! = 1 × 0!, so 0! must be 1.
How many digits does 1000 factorial have?
2,568 digits. The count comes from adding the logarithms of every factor, so it can be worked out without building the number. A million factorial has 5,565,709 digits.
How many trailing zeros does 100! have?
24. Count the factors of five: 100 divided by 5 is 20, and 100 divided by 25 is 4, giving 20 + 4 = 24. There are far more twos than fives, so the fives decide it.
What is the largest power of 3 that divides 100!?
3 to the power 48. Add the whole-number parts of 100/3, 100/9, 100/27 and 100/81: that is 33 + 11 + 3 + 1 = 48. The same method works for any prime.
Can you take the factorial of a negative number?
No. Running the recurrence downwards past zero requires dividing by zero, so no value exists. Negative factorials are undefined rather than merely unknown.
What is the factorial of a decimal such as 4.5?
The factorial itself is defined only on whole numbers. There is a smooth curve through the factorial values called the gamma function, and 4.5 has a value on it, but that is a different function and this page refuses rather than returning it under the factorial sign.
Why does my calculator show 9.33e+157 for 100!?
Ordinary calculators store numbers with about fifteen significant figures, and 100! has 158 digits. Anything past 20! stops fitting, so the display switches to a rounded shorthand. This page keeps whole numbers throughout.

Multiply downwards to get the number; divide n by five, then twenty-five, then a hundred and twenty-five, to know how it ends.