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?