How it works
A number ends in as many zeros as the number of times 10 = 2 × 5 divides it. In n! there are always more 2s than 5s, so just count the 5s:
⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + …
The first term counts the multiples of 5, the second adds one more for each multiple of 25 (which contributes two 5s), and so on. Stop when the power of 5 is bigger than n.
Going backwards ("smallest n with 10 zeros"), note that the count only increases at multiples of 5, and it jumps by 2 at multiples of 25. Some counts are skipped entirely: no factorial ends in exactly 5 zeros.
Trailing Zeros In Factorials practice problems with solutions
These problems come from Mathyessy's question bank. Try each one before opening the solution.
How many trailing zeros does 25 factorial have?
Show answer and solution
Answer: 6
⌊25/5⌋ + ⌊25/25⌋ = 5 + 1 = 6.
How many trailing zeros does 100 factorial have?
Show answer and solution
Answer: 24
⌊100/5⌋ + ⌊100/25⌋ = 20 + 4 = 24. (125 is bigger than 100, so stop.)
How many trailing zeros does 1000 factorial have?
Show answer and solution
Answer: 249
⌊1000/5⌋ + ⌊1000/25⌋ + ⌊1000/125⌋ + ⌊1000/625⌋ = 200 + 40 + 8 + 1 = 249.
What is the smallest n so that n factorial has 10 trailing zeros?
Show answer and solution
Answer: 45
40! has 8 + 1 = 9 zeros, and 41! to 44! add no new 5s. 45! adds one more 5, giving 10 zeros, so n = 45.
Keep going
Related topics
Related practice sets in the app
All Number Theory topics · Contest math practice by topic · MATHCOUNTS practice · AMC 8 practice