as we know for divisibilty of 10..any number must be divisible by 2 and 5...so whenever we want no of 0's at the end of any number..it will simply show how much time we can we can divide this number by 10...now The idea is to consider prime factor of a factorial n.If we can count the number of 5s and 2s, our task is done.Consider the following examples.
n = 5: There is one 5 and 3 2s in prime factors of 5! =(2 * 2 * 2 * 3 * 5).no. of zero=1
n = 11: There are two 5s and three 2s in prime factors of 11! (2 8 * 34 * 52 * 7). no of zero at the end=2
We can easily observe that the number of 2s in prime factors is always more than or equal to the number of 5s. So if we count 5s in prime factors, we are done. now
Count of 5s in prime factors of n!
= floor(n/5) + floor(n/25) + floor(n/125) + ....