Factorial Calculator
Result
Factorial
- Digits
- 3
- Trailing zeros
- 1
A factorial calculator multiplies every whole number from 1 up to n and reports the product, together with two readings that say how big it got: how many digits the answer has, and how many trailing zeros it ends in. The factorial of 5 is 120 — three digits, one trailing zero. The result leaves the readable range quickly, and past 21 the main reading switches to scientific notation, but the digit count and the trailing zeros stay exact, because both come from formulas rather than from counting characters off a printed value. The factorial of 0 is 1, the empty product, and 170 is the largest input accepted here: 171 factorial overflows what a double can hold and is refused rather than answered with infinity.
Factorials from 0 to 12
| n | Factorial | 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 | 5040 | 4 | 1 |
| 8 | 40320 | 5 | 1 |
| 9 | 362880 | 6 | 1 |
| 10 | 3628800 | 7 | 2 |
| 11 | 39916800 | 8 | 2 |
| 12 | 479001600 | 9 | 2 |
The first thirteen factorials, with the two readings beside each one. The rows are here to make the growth visible: the value passes a thousand by the seventh row and a hundred million by the twelfth, while the digit count climbs one at a time and the trailing zeros stay at zero until the number contains a 5. Reading down the last column shows why 5, 10 and 12 matter and 11 does not. Every cell is a plain number, so the table is identical in all ten languages the site serves.
Formula
n! = 1 × 2 × … × n digits = ⌊log₁₀(n!)⌋ + 1 trailing zeros = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
- n
- The number whose factorial is wanted: a whole number from 0 to 170. It is also the count of factors, since the product runs from 1 up to n. The upper limit is not a display choice — 171 factorial exceeds the largest value a double can represent, so anything above 170 has no answer to give.
- n!
- The factorial itself, the product of every whole number from 1 to n. It outgrows an exponential curve: 5 factorial is 120 while 10 factorial is already 3,628,800. Once the value passes a million the printed answer becomes scientific notation, which keeps the magnitude readable without printing a hundred digits.
- digits
- How many decimal digits the factorial has. It is computed by adding up logarithms rather than by counting the characters of a printed value, so it stays correct even at the top of the range, where the printed factorial carries only seven significant figures.
- trailing zeros
- How many zeros sit at the end of the factorial. Every trailing zero needs a factor of 10, which needs one 2 and one 5; twos appear far more often than fives in a factorial, so the count is decided entirely by the fives — every multiple of 5, of 25, of 125 and so on contributes one more.
Reach for this when the value itself is the answer: the number of ways to arrange a whole set, a term in a series, or the size of a product. To choose r items out of n, the combinations and permutations pages divide one factorial by another rather than multiplying.
Worked examples
The factorial of 5
- Multiply upwards: 1 × 2 = 2
- 2 × 3 = 6
- 6 × 4 = 24
- 24 × 5 = 120
- 120 has three characters and ends in one zero, so the two readings are 3 and 1
The smallest case where all three readings can be checked by eye. The product is short enough to read in full, and the digit count and the trailing zeros are both visible by looking at it — which is exactly why this is the value the page opens on.
Where the reading turns into scientific notation
- Multiply from 1 up to 20, which is 2,432,902,008,176,640,000 exactly
- That is nineteen digits, so the digit reading is 19
- Four of those digits are zeros at the end, which the fives in 5, 10, 15 and 20 account for
- The panel prints the product as 2.432902 × 10¹⁸ rather than as the full nineteen-digit number
The point where the printed value stops being the exact value. The digits shown are the leading seven significant figures of the same number the two readings describe, so the three outputs agree even though only one of them is short enough to print. Below 21 the printed product is exact.
How many zeros 100 factorial ends in
- Count the multiples of 5 up to 100: 20 of them
- Add the multiples of 25, which carry a second five: 4 of them
- Add the multiples of 125 — none, since 125 is past 100
- 20 + 4 = 24 trailing zeros
- The factorial itself is 158 digits long, printed as 9.332622 × 10¹⁵⁷
The count of zeros is the readable fact here, and it is worked out from the fives alone rather than from the number. 100 factorial has 158 digits, so its ending could not be inspected by eye even if all of them were printed.
Limitations
Only whole numbers from 0 to 170 are accepted. Negative inputs are refused because the factorial is not defined on them — the Gamma function, which extends the factorial to other numbers, has a pole at every negative integer. Fractions are refused for the same reason. Above 170 the product overflows a double and would come back as infinity, so the input is rejected by name instead. Past 21 the printed factorial is a scientific-notation approximation rather than the exact integer; the digit count and the trailing zeros remain exact regardless, and together they describe the size of a number whose digits are not all shown. This page does not compute binomial coefficients or permutations directly — it gives the factorial those pages are built from.
Frequently asked questions
- What is a factorial?
- The product of every whole number from 1 up to the number you give. The factorial of 5 is 1 × 2 × 3 × 4 × 5, which is 120. It counts the number of ways a set of that many distinct items can be arranged, which is why it turns up in probability and in counting problems rather than in measurement.
- Why is 0 factorial equal to 1?
- Because it is an empty product — there is nothing to multiply, and the value that leaves a product unchanged is 1. The convention is not arbitrary: it is what makes the counting interpretation work (there is exactly one way to arrange nothing) and what keeps the recurrence n! = n × (n−1)! true at n equal to 1.
- Why does the calculator stop at 170?
- Because 171 factorial is larger than the biggest number a double-precision float can represent, so the calculation returns infinity. The limit is not a choice about display: every input above 170 has no representable answer. 170 factorial is itself about 7.26 × 10³⁰⁶, a 307-digit number.
- How are the trailing zeros counted?
- By counting the factors of five in the factorial. A trailing zero needs a 10, and a 10 needs one 2 and one 5; twos are abundant, so the fives decide it. Every multiple of 5 contributes one, every multiple of 25 contributes a second, every multiple of 125 a third, and so on. For 100 factorial that is 20 + 4 = 24 zeros.
- Why is the factorial printed in scientific notation?
- Because past 21 the value has more digits than a result panel can usefully show — 100 factorial has 158 of them. Scientific notation keeps the magnitude legible. The exact integer is still what the two other readings describe: the digit count tells you how long it is, and the trailing zeros tell you how it ends.
- How many digits does a large factorial have?
- The digit reading answers that exactly, at every input the page accepts. It comes from adding up logarithms rather than from measuring a printed string, so it does not lose accuracy when the printed value is an approximation. The count is always at least one more than the number of trailing zeros.
References
- Factorial — the definition, the empty product convention that makes 0! equal 1, and the rate at which the value grows — Wolfram MathWorld (United States)
- A000142 — the factorial numbers 1, 1, 2, 6, 24, 120 … as a catalogued sequence, with exact values far beyond the range a double can hold — OEIS Foundation (United States)
- Combination — the binomial coefficient, written as one factorial divided by two others, which is where factorials are most often needed — Wolfram MathWorld (United States)