How many trailing zeros does 1000! have?

“!” is the factorial symbol. For example, 12! = 12 x 11 x 10 x … x 2 x 1 = 479001600, which has 2 trailing zeros (zeros at the end of the number).


Solution

249 trailing zeros

A trailing zero is added whenever a number is multiplied by 10. To figure out how many factors of 10 there are, just figure out how many factors of 2 and 5 there are (whichever is fewer).

It’s easy to see that a factorial contains many more factors of 2 than factors of 5, so we just need to figure out how many factors of 5 there are.

1 out of every 5 numbers in the factorial is a factor of 5. However, factors of 25 contains two factors of 5, so they need to be counted twice, and so on for other powers of 5.

So there are:

  • 1000 / 5 = 200 factors of 5
  • 1000 / 25 = 40 factors of 25
  • 1000 / 125 = 8 factors of 125
  • 1000 / 625 = 1.6 factors of 625 (which rounds down to just 1 factor, 625 itself)

200 + 40 + 8 + 1 = 249

Leave a Reply

Your email address will not be published. Required fields are marked *