Why does 5000 factorial have 1249 trailing zeros and not 1248

391 Views Asked by At

I was taught a short cut to calculate the number of trailing zeros, as basically repeatedly divide by 5 until you get a result less than 5. Example:

75 factorial = 75/5 = 15 / 5 = 3, 15+3 = 18 trailing zeros.

So taking that theory, I do the following:

5000 factorial = 5000/5 = 1000 / 5 = 200 / 5 = 40 / 5 = 8, so I expect 1248 trailing zeros

But everywhere I look, they say the answer is 1249.

2

There are 2 best solutions below

0
On

Adam! The tip is correct. Thing is, you stopped at $8$ as it was less than 5. Since it isn't, you just need to add one more division and it'll be good!

0
On

Quick Tip: If you have $k!$ and if you want to find the exponent of the prime $p$ in this number, all you have to do is $\displaystyle \sum _{r=1}\left[\frac{k} {p^{r}}\right] $ where [] is the floor function. (basically get rid of the decimals) until $ k/p^r$ is less than one.
So in your case, you found the exponent of just 5 because no of 5 in k! is less than no of 2 appearing in k!.
So doing this:$[5000/5]+[5000/25]+[5000/125]+[5000/625]+[5000/3125] = 1000+200+40+8+1 = 1249.$