How to use the Factorial Calculator
- Enter a whole number n from 0 to 1,000.
- Read n! in full, or in scientific form if it has more than 40 digits.
- Check the digit count and the number of trailing zeros.
Formula used
n! = n × (n − 1) × … × 2 × 1, and 0! = 1. Trailing zeros = ⌊n ÷ 5⌋ + ⌊n ÷ 25⌋ + ⌊n ÷ 125⌋ + …
Worked example
Here is the Factorial Calculator worked through with the example values shown above, so you can check each step by hand.
| Inputs | |
|---|---|
| Whole number (n) | 20 |
| Result | |
| n factorial | 2,432,902,008,176,640,000 |
| Number of digits | 19 |
| Trailing zeros | 4 |
What a factorial is
5! = 5 × 4 × 3 × 2 × 1 = 120. By definition 0! = 1, which keeps formulas such as the number of combinations working for every case. The default of 20! equals 2,432,902,008,176,640,000, a number with 19 digits.
Factorials grow faster than powers. Each step multiplies by a larger number, so the result quickly becomes enormous.
Exact answers for big numbers
The calculator uses exact whole-number arithmetic, not decimal approximation, so every digit is correct. For example 100! has 158 digits and begins 9.332621 × 1, written in the form shown. Numbers with more than 40 digits are shown in scientific notation to stay readable.
The limit of 1,000 keeps the page fast. 1,000! already has over 2,500 digits.
Trailing zeros
A zero at the end of a number comes from a factor of 10, which is a 2 times a 5. Factorials have plenty of 2s, so the count of 5s decides the number of zeros. The formula is ⌊n ÷ 5⌋ + ⌊n ÷ 25⌋ + ⌊n ÷ 125⌋ and so on. For 20! that gives 4, and for 100! it gives 24.
This is a popular exam question, and it is much faster than computing the factorial and counting the zeros.
Where factorials are used
Permutations use n! to count orderings, and combinations divide by factorials to remove the repeated ones. Probability problems, Taylor series, the binomial theorem and many counting arguments all rely on them.
For those uses, the permutation and combination calculator on this site applies the formulas directly, and avoids computing huge factorials when it does not have to.
Factorials in counting problems
The number of ways to arrange 5 different books on a shelf is 5! = 120. Arranging 10 people in a queue can be done in 3,628,800 ways. Because the numbers explode so quickly, factorials show why brute-force searching through every ordering becomes impossible for even modest sizes.
In combinations, you choose r items from n without caring about order, using n! ÷ (r! × (n − r)!). Cancelling common factors by hand is far easier than computing both huge factorials, which is what the combination calculator does.
Frequently asked questions
What is 0 factorial?
1, by definition.
Can I take the factorial of a negative number?
No, the ordinary factorial is defined only for whole numbers zero or higher.
Can I find the factorial of a decimal?
Not with this calculator. The gamma function extends it to decimals, which is a different tool.
Why is the limit 1,000?
It keeps results fast and readable. Larger values have thousands of digits.
How many zeros does 100! end with?
24, from ⌊100 ÷ 5⌋ + ⌊100 ÷ 25⌋.
Is the result exact?
Yes, it uses exact integer arithmetic. Only the display of very large values is shortened.
This calculator gives estimates for information only. Actual figures from a bank, employer, tax authority or doctor may differ. It is not financial, tax, legal or medical advice.