Factorial trailing zeros calculator
Count terminal zeroes in n factorial without calculating the huge integer. Enter your numbers below to see the result and method.
inputs.
Related calculators and articles
Compare methods and explore more free tools in math.
How to use this calculator
Free Factorial trailing zeros calculator. Count terminal zeroes in n factorial without calculating the huge integer. Review the formula and assumptions.
- Enter Non-negative integer n. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Count factors of ten in n factorial
A trailing zero in base ten contributes one factor of 10 = 2 × 5. In n!, factors of 2 are more plentiful, so the number of trailing zeros is set by the number of factors of 5.
Input and domain
- Non-negative integer n: Enter a whole number n ≥ 0. The calculator counts zeros without constructing the very large integer n!.
Formula and method
Zeros(n!) = ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + ⋯
Each multiple of 5 contributes at least one factor of 5; multiples of 25 contribute one additional factor, multiples of 125 another, and so on. Stop when the power exceeds n.
Worked example
For n = 100, the contributions are ⌊100/5⌋ = 20 and ⌊100/25⌋ = 4. Higher powers contribute zero, so 100! ends in 20 + 4 = 24 zeros.
Interpretation and limits
The result is an exact count of base-ten trailing zeros, not the value of n!. At n = 0 the empty product is 1, so the count is zero. The input must be a non-negative integer.
Frequently asked questions
Why do powers of five determine the count?
Each trailing zero needs a factor pair 2 × 5. A factorial contains more factors of 2 than 5, so the number of factors of 5 is limiting.
Why add the terms for 25 and 125?
A multiple of 25 contains two factors of 5, and a multiple of 125 contains three. The extra floor terms count those additional factors.
Is n = 0 allowed?
Yes. Zero factorial is 1 and has no trailing zeros, so the calculator returns 0.
How do I use the Factorial trailing zeros calculator?
Enter Non-negative integer n. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Factorial trailing zeros?
For n = 100, the contributions are ⌊100/5⌋ = 20 and ⌊100/25⌋ = 4. Higher powers contribute zero, so 100! ends in 20 + 4 = 24 zeros.
Read the calculation methodology.