rec.puzzles Archive

How many trailing zeros are in the decimal expansion of n!?

arithmetic/digits/zeros/trailing

Problem

How many trailing zeros are in the decimal expansion of n!?
Show solution
The general answer to the question
"what power of p divides x!" where p is prime
is (x-d)/(p-1) where d is the sum of the digits of (x written in base p).

So where p=5, 10 is written as 20 and 10! is divisible by 5^2 (2 = (10-2)/4);
x to base 10:     100    1000    10000    100000     1000000
x to base 5:      400   13000   310000  11200000   224000000
d          :        4       4        4         4           8
trailing 0s in x!  24     249     2499     24999      249998