## Trailing Zeroes

#### Problem

13! = 13 12 11 ... 2 1 = 6227020800, and it can be seen that 13! contains two trailing zeroes.

How many trailing zeroes does 1000! contain?

#### Solution

Every time a number is multiplied by 10 an extra trailing zero is added, and as 10 = 2 5, we need only consider the number of factors of 5 present in 1000!; there are an abundance of factors of 2.

There are 1000/5=200 factors of 5, but we must also ensure that we take into account 25 = 5 5, which contains two factors of 5; hence there will be 1000/25=40 extra factors of 5. Similarly, 125 = 5^{3}, contains three factors of 5, and 625 = 5^{4}.

1000/5 = 200, 1000/25 = 40, 1000/125 = 8, and 1000/625 = 1.6.

Therefore, 1000! contains, 200 + 40 + 8 + 1 = 249 trailing zeroes.

How many trailing zeroes does `n`! contain?