next up previous
Next: Prime numbers Up: Inaugural UTICPC Previous: Master of my domain

How many zeroes?

One of my favourite things to do on Maple, a symbolic algebra program, is to waste time computing factorials. For instance,

However, I've noticed that as I compute larger and larger factorials, there are more and more zeroes on the end (when written down in decimal notation). I want to know, just how many?

Input: The input to your program is a positive integer d, followed by d data sets. Each data set consists of a positive integer n, with n<10000.

Output: The output for each n should be z(n), the number of trailing zeroes in the decimal expansion of n!. That is, divides evenly into n!, but does not.

Sample input:

3
2
6
10

Corresponding sample output:

0
1
2



David Neto
Thu Jan 9 19:12:26 EST 1997