This question is not homework, just asked out of curiosity. I wondered how many zeroes could be found at the end of $1990!$ . I computed something that seemed to work and found out 439. So I computed it in Python, and it returned 494 zeroes, so I'm 55 short.

My reasoning went like this : I get 2 zeroes by series of 10 consecutive numbers. The one that can be divided by 10 gives one zero, and I get another one from the multiplication of the one ending with 2 and the one ending with 5. So 199*2 = 398. But I also have 2 zeroes by hundreds, one comming from the one divisible by 100, and one from XX20 * XX50. 19*2 = 38 more. Then same for thousands. I only get 3 zero more, from 1000, 200*500 and 1200*1500.

$398 + 38 + 3 = 439$

So here is my question:

How can I compute function $t0(n)$ where $t0(n)$ returns the number of trailing $0$ in $n! = factorial(n)$ ?

(Assume $factorial(n)$ is written in base 10, but even better for any base !)