I would like to find the first $n!$ such that $(\text{The number of trailing zeros in }n!)\geq 10000$.
By following the method in this post, If we represent $n$ in base $5$($n=a_0 + 5a_1 +25a_2+\cdots)$, we get:
$ [n/5]+[n/25]+[n/125]+\cdots = a_1 + 6a_2 + 31a_3 + 156a_4 + 781a_5 +3906a_6 + 19531a_7\cdots$
where $0 \leq a_k \leq 4$, and this is equal to the number of trailing zeros in $n!$, according to the Legendre formula.
$19531$ is already excessive, so we can assume that $a_k=0$ for $k\geq 7$. Now we have to find the smallest $n$ such that
$a_1 + 6a_2 + 31a_3 + 156a_4 + 781a_5 +3906a_6 \geq 10000$.
But I am not sure how. Obviously, brute force is an option, but I would like a more "elegant" solution.
How can I continue?
The highest power of $2$ dividing $n!$ is $\lfloor \frac{n}{2} \rfloor+\lfloor \frac{n}{4} \rfloor+\lfloor \frac{n}{8} \rfloor+...$
The highest power of $5$ dividing $n!$ is $\lfloor \frac{n}{5} \rfloor+\lfloor \frac{n}{25} \rfloor+\lfloor \frac{n}{125} \rfloor+...$
For $n!$ to have more than $10000$ trailing zeros, it is necessary and sufficient to have $\lfloor \frac{n}{5} \rfloor+\lfloor \frac{n}{25} \rfloor+\lfloor \frac{n}{125} \rfloor+... \geq10000$ (since this inequality is then automatically statisfied for $2$ instead of $5$)
This means $n \leq 50000$ (due to the first term), and using the fact that $\lfloor \frac{n}{5} \rfloor+\lfloor \frac{n}{25} \rfloor+\lfloor \frac{n}{125} \rfloor+...$ is increasing in $n$, it can be possible to isolate the solution through trial and error (bisection).
For instance, for $n=40000$, we get $\lfloor \frac{n}{5} \rfloor+\lfloor \frac{n}{25} \rfloor+\lfloor \frac{n}{125} \rfloor+...=9998$ so that would be $9998$ trailing zeros, so it must be close to this number. $40005\leq n \leq 40009$ yields $9999$ and $40010$ yields $10000$ so the answer is $n=40010$. This came from an educated guess but did not require too many calculations