Can anyone give me a generalized way to find the number of zeroes trailing at the end of $n!$ ?
-
I don't understand your question, what is the "end of n" supposed to be? – lattice May 31 '16 at 06:59
-
10Is that n factorial, n double factorial, (n factorial) factorial, or just a really excited n? – f'' May 31 '16 at 07:03
-
Related: http://math.stackexchange.com/questions/286947 – Bart Michels May 31 '16 at 07:04
-
1Assume $n!!$ means double factorial, when $n$ is odd, the $n!!$ is odd and the number of trailing zeros of its decimal representation is $0$. If $n = 2m$ is even, then $n!! = 2^m m!$, the problem reduce more or less to the problem of how many trailing zeros in $m!$ which are covered by the link provided by barto and also by the answers. – achille hui May 31 '16 at 07:26
1 Answers
The number of zeroes at the end of $n!$ is
$$f(n) = \large \sum_{i=1}^{\log_5n} \lfloor\frac{n}{5^i}\rfloor$$
In simpler terms, it's basically the largest power of $5$ that divide $n!$.
Explanation: Okay. Well, a number is divisible by $10$ if it is divisible by both $5$ and $2$. The largest power of $10$ that divides it is simply the minimum of the largest power of $5$ that divides it or $2$ the largest power of $2$ that divides it. It is obvious that the power of $2$ dividing $n!$ is larger than the power of $5$ dividing $n!$. So, we find the largest power of $5$ that divides $n!$. Now what you might do is simply divide $n$ by $5$ which is incorrect. You see, there exist numbers like $25$ which are divisible by $5^2$. So, you have to count them again.
Then find $f(n!)$. You are done.

- 4,014
- 2
- 20
- 56