Generalised Question : Is there any way to find the number of zeroes at the end of $n!$ for $n\ge5$ ?$\\$
I recently came across a question in which it was asked to find the number of zeroes at the end of $1000!$ , I tried doing that and I noticed that every $5k!$ where $k \in \mathbb N$ had one greater $0$ than it's predecessor i.e. ($4! = 24$, $5! = 120$) ; ($9! = 362880$, $10! = 362800$), hence by induction I came to prove that $1000!$ should have $200$ zeroes but the answer was $249$. $\\$
Where did I go wrong ? $\\$
Any help would be appreciated. Thanks !!
-
1$\begingroup$ en.wikipedia.org/wiki/Trailing_zero#Factorial $\endgroup$– GaryMay 11, 2021 at 6:01
3 Answers
Yes, there is. It is called de-Polignac's formula, which I suggest you look up. It is given by $p=\sum_{i=0}^\infty \lfloor \frac {n}{5^i} \rfloor$. Note that after $n<5^m$, for some $m$, all subsequent terms would be zero and no further calculation would be required.
You can also find out the power of $5$ in the prime factorization of $n!$, which would be the number of $0s$ required.
-
2$\begingroup$ Welcome to Mathematics Stack Exchange. It is also known as Legendre's formula $\endgroup$ May 11, 2021 at 22:02
You have only counted the $5$ of numbers like $25,125, 250, 1000$ etc. once each. But these have more than one $5$ in their factorisations. The correct method is as follows:
Count one $5$ from each of these numbers once: $$5,10,15,20,25,30,.....1000$$ We get $\left\lfloor\frac{1000}{5}\right\rfloor=200$ of these $5$'s.
Now count another $5$ from each multiple of $25$ (note that we have already counted one $5$ from each of these!) $$25,50,75,100,.....1000$$ We get $\left\lfloor\frac{1000}{25}\right\rfloor=40$ of these $5$'s.
Now count another $5$ from each multiple of $125$ (we have already counted two $5$s from each) $$125,250,375,.....1000$$ We get $\left\lfloor\frac{1000}{125}\right\rfloor=8$ of these $5$'s.
Finally, count another $5$ from each multiple of $625$ (we have already counted three $5$s from them) $$625$$ We get $\left\lfloor\frac{1000}{625}\right\rfloor=1$ of these $5$'s.
Adding all of these up, the maximum power of $5$ in $1000!$ is $200+40+8+1=249$. Obviously, the maximum power of $2$ is much more, so we won't bother about it. The maximum power of $10$ is therefore equal to the maximum power of $5$, that is $249$.
So $1000!$ has $249$ zeroes at the end.
There is a technique that works due to Legendre's formula .
- Convert $n$ to base $5$.
- Add up the digits.
- Subtract the sum from $n$
- Divide by $4$
Converting from base $10$ to base $5$ is one of the easier conversions, especially starting with the least significant digit. Since $1000_{10}$ = $13000_{5}$, $$z(1000!) = \frac{1000 - (1 + 3 + 0 + 0 + 0)}{4} = 249$$