Answer to old chestnut: trailing zeroes:

The key to solving this problem is realizing that the number of trailing zeroes in a number is the number of times that number is divisible by ten. Divisibility by ten requires prime factors of two and five, and thus, the answer is the power of either two or five in the prime factorization of the number which is smaller.

Now in a factorial, we are going to get one factor of 2 for each even number in the product (or thus half the number factorialized, rounded down), plus an additional one for each multiple of 4 in the product, plus an additional one for each factor of 8 in the product, and so on. Factors of 5 work the same way, but based on multiples of 5, 25, 125, etc. There are less of the latter, so fives are the limiting quantity.

The argument above provides the answer we need. For N!, there are {n/5} (where {x/y} represents x/y rounded down to an integer) multiples of 5, {n/25} multiples of 25, {n/125} multiples of 125, etc. (eventually this stops because the powers become greater than N and thus there are no more).

For 1000!, we have 200 + 40 + 8 + 1 = 249.

Log in or register to write something here or to contact authors.