Factorial Calculator (n! up to 170)
Enter a whole number n to get n! (n factorial), how many digits it has and how many zeros it ends with.
Updated
Report a problem
Formula
n! = n × (n − 1) × (n − 2) × … × 2 × 1, with 0! = 1.
The number of digits is floor(log10(n!)) + 1. Trailing zeros are floor(n/5) + floor(n/25) + floor(n/125) + ….
Worked example
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800.
- It has 7 digits.
- Trailing zeros: floor(10/5) = 2.
For larger values, 100! has 158 digits and is about 9.332622 × 10^157, and 170! has 307 digits.
Frequently asked questions
What is a factorial?
n! is the product of all whole numbers from 1 up to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120. It counts the ways to arrange n different items in a row.
Why is 0! equal to 1?
There is exactly one way to arrange zero items (do nothing), and defining 0! = 1 keeps formulas such as n! = n × (n − 1)! and combinations working.
Why does this calculator stop at 170?
170! is about 7.257 × 10^306 and has 307 digits, the largest factorial that standard double-precision numbers can represent. 171! is too large for most calculators and software.
How many zeros does n! end with?
Count the factors of 5: divide n by 5, 25, 125 and so on, round each down and add them. For 25 that is 5 + 1 = 6, so 25! ends in 6 zeros.