How many trailing zeroes in $52!$?

89 Views Asked by At

Problem

How many trailing zeroes are there in $52!$ ?

My thoughts

I believe I correctly solved it, but I'm not happy with the scalability of my method.

I figure the number of trailing zeroes is equal to the number of times $52!$ is divisible by 10. I wrote out every integer from 1-52 that is divisible by 2 or 5. The idea being that the number of 2 AND 5-factors equals the number of 10-factors.

I quickly noted that the number of 2-factors is greater than the number of 5-factors, so I figured finding the number of 5-factors will do. There were 12.

I'm not very happy with this, because if they now ask me to do the same for $152!$, I'll have to tell them to shove it. I'm not doing this again.

Question

Is there a better way to do this? Perhaps a method that scales better?

1

There are 1 best solutions below

0
On

You get your $12$ by counting $\left\lfloor\frac{52}{5}\right\rfloor+\left\lfloor\frac{52}{25}\right\rfloor$. This counts each multiple of $5$ in the product $52!$, then adds on a count for each multiple of $25$. This can generalize to $152$. You'll need to go up to $125$ with divisors.

In general, the number of trailing $0$s in $n!$ will be $$\sum_{k=1}^{\infty}\left\lfloor\frac{n}{5^k}\right\rfloor$$ where for any $n$, only the first few terms in that infinite sum will be nonzero.