How it’s calculated
The factorial of a non-negative whole number n, written n!, is the product of all the whole numbers from 1 up to n. By definition 0! = 1. Factorials count the ways to arrange n different things in order, and they appear in permutations, combinations and the binomial theorem.
They grow extremely fast, so the calculator uses exact big-integer arithmetic instead of ordinary decimals, which would lose precision beyond 20!. Very long results are shown to the first 300 digits followed by an ellipsis (…); the digit count and scientific notation always describe the whole number. The number of trailing zeros equals the number of factors of 5 in the product: ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
Example: 5! = 5 × 4 × 3 × 2 × 1 = 120. And 20! = 2,432,902,008,176,640,000 (19 digits, about 2.4329 × 10¹⁸, with 4 trailing zeros).
Frequently asked questions
Why is 0! equal to 1?
It is a convention that keeps formulas consistent. There is exactly one way to arrange zero items (do nothing), and it makes the combination formula C(n, 0) = n! ÷ (0! n!) equal to 1, as it should.
Can I take the factorial of a negative number or a decimal?
Not with the ordinary definition. The gamma function extends factorials to non-whole numbers (n! = Γ(n + 1)), but this calculator only handles whole numbers 0 and up.
What is the largest factorial this can calculate?
3,000! exactly, which has 9,131 digits. Beyond that the number is too long to be useful to read; use scientific notation or logarithms instead.
How many zeros are at the end of a factorial?
Count the factors of 5, since each pair of 5 and 2 makes a 10. For 100! that is 20 + 4 = 24 trailing zeros.
Embed this calculator
Add this free calculator to your own website. Copy the code below into your page’s HTML:
Need this calculator branded, changed or built around your own prices?See custom business solutions →
Sources
- College Algebra 2e, §9.6 Binomial Theorem (factorial notation) — OpenStax
- Precalculus 2e, §11.6 Binomial Theorem (factorial notation) — OpenStax
- NIST Digital Library of Mathematical Functions, §5.4 Special Values (n! = Γ(n + 1)) — NIST
Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.
Added · Last updated · How we check our calculators
Spotted a mistake or missing option? Report a problem· Suggest a calculator