# Number of zeros at the end of $k!$

### For how many positive integer $k$ does the ordinary decimal representation of the integer $k\text { ! }$ end in exactly $99$ zeros ?

By inspection I found that $400\text{ !}$ end in exactly $99$ zeros , but $399\text{ !}$ does NOT end in $99$ zeros ; using the formula $$\text{ number of zeros at the end }=\sum_{n=1}^{\infty}\left[\frac{k}{5^n}\right]$$where , $[x]$ denotes the greatest integer part not exceeding $x$.

I also found that, for $k=401,402,403,404$ the number of zeros is same, but for $k=405$ the number of zeros increase by $1$ ; as $405$ is divisible by $5$ again , after $400$.

Thus I got that there are only $5$ integers satisfying the condition which are $400,401,402,403,404$.

The question is possible duplicate of this or this but my question is different from these two questions.

Does there exist any other rule or easy formula from where I can get how many integers are there

• There are always $5$ or none. – André Nicolas Aug 4 '15 at 18:01
• @@ André Nicolas)Yes...There are always $5$..It is clear..But how none ? – Empty Aug 4 '15 at 18:02
• For example $400!$ has $99$. But the number $400$ contributes $2$, so there are none with exactly $98$. – André Nicolas Aug 4 '15 at 18:04
• @ André Nicolas ) Sir , it is NOT clear to me. Can you give me more detail ? I am unable to understand how there are no integer whose factorial contains exactly $98$ zeros .. – Empty Aug 5 '15 at 15:08
• You know how to compute the number of terminal $0$'s of $n!$. Compute the number for $n=395$ (or $396$, or $397$, or $398$, or $399$). You will find that the number is $97$. Then at $400$ there is a jump to $99$, missing $98$. There is a jump of that kind, and a corresponding gap, at any multiple of $25$. There is a bigger jump of $3$ (so $2$ missing values) as we go from $124!$ to $125!$, and so on. – André Nicolas Aug 5 '15 at 15:16

## 1 Answer

Because the number of zeroes steps up at each multiple of $5$, the only possible answers are five or zero. So the question might be: How to determine of there exists $k$ such that $k!$ ends in a given number of zeroes?

Say we want $m$ zeroes. So we look for $k$ with $$m=f(k):=\sum_{i=1}^\infty\left\lfloor \frac k{5^i}\right \rfloor$$ First note that $$\tag1f(k)<\sum_{i=1}^\infty\frac k{5^i}=\frac k4$$ and on the other side $$\tag2f(k)\ge \sum_{i=1}^{\lfloor \log_5k\rfloor}\left( \frac k{5^i}-1\right )> \frac k4-\lfloor \log_5k\rfloor-\frac 54>\frac k4-\log_5k-\frac 94$$ For $k\ge 3$, the right hand side of $(3)$ is strictly increasing. Therefore we start our search at $k=4m+1$ and end it no later than $k=4m+4\log_5(4m+1)+9$. Unless $m$ is awfully large, this requires us to try just a few values of $k$ (recall that we only need to try multiples of $5$).