Could this approximation be made simpler ? Solve $n!=a^n 10^k$
I need to find the smallest value of $n$ such that $$\frac{a^n}{n!}\leq 10^{-k}$$ in which $a$ and $k$ are given (these can be large numbers).
I set the problem as : solve for $n$ the equation $$n!=a^n\, 10^k$$ I used for $n!$ Stirling approximation in which I ignored the $\sqrt n$ term. This gives an upper bound of the solution I rewrote as $$n_0=a\,e\, \frac A {W(A)}$$ $W$ being Lambert function and $$A=\frac{k \log (10)- \log (\sqrt{2 \pi} )}{a\,e }$$ which is not too bad (for example, using $k=1000$, $a=100$, the approximation gives $n_0\approx 1402.65$, the algebraic solution being $n\approx 1401.27$).
At this point, I could go backwards and find the solution. This is what I should call brute force.
For sure, starting from this estimate $n_0$, I could perform one iteration of Newton method and get $$n_1=n_0-\frac{\log (\Gamma (n_0+1))-(n_0 \log (a)+k \log (10))}{\psi (n_0+1)-\log (a)}$$ which is still an upper bound (Darboux theorem). Similarly, I could do the same using Stirling approximation and get $$n_1=n_0-\frac{\left(n_0+\frac{1}{2}\right) \log (n_0)-n_0 (1+\log (a))-k \log (10)+ \log (\sqrt{ 2 \pi })}{\frac{1}{2 n_0}+\log (n_0)-\log (a)}$$
However, using the rigorous formulation, this makes the second calculation quite expensive for little improvement and I wonder if something simpler could be considered.
Edit
It is sure that for a given value of $k$, the problem would be much simpler since I could perform a least square fit for a model $$n=\frac{\alpha}{W\big(\frac{\beta}a\big)}$$ and the results are quite good; for example, if $k=1000$, $\alpha=2298.64$, $\beta=845.965$ (to be compared to $\alpha_0=2301.67$ and $\beta_0=846.736$ from the initial model). For $a=100$, this would give $n=1401.28$ which is the answer. The problem is that many $k$'s have to be considered and curve fit does not look to be a solution.
Stirling's Formula says $$ \log\left(\frac{a^n}{n!}\right) \sim -n\log\left(\frac n{ea}\right)-\frac12\log(2\pi n)\tag{1} $$ Multiplying by $-\frac1{ea}$ and subtracting $\frac1{2ea}\log(2\pi ea)$, we get $$ \begin{align} -\frac1{ea}\log\left(\frac{a^n}{n!}\sqrt{2\pi ea}\right) &\sim\frac{n}{ea}\log\left(\frac n{ea}\right)+\frac1{2ea}\log\left(\frac n{ea}\right)\\ &=\frac{n+\frac12}{ea}\log\left(\frac n{ea}\right)\\ &\approx\frac{n+\frac12}{ea}\log\left(\frac{n+\frac12}{ea}\right)-\frac1{2ea}\tag{2} \end{align} $$ Applying the Lambert W Function to $(2)$ gives $$ n\sim ea\exp\left(\operatorname{W}\left(-\frac1{ea}\log\left(\frac{a^n}{n!}\sqrt{2\pi a}\right)\right)\right)-\frac12\tag{3} $$ Plugging in $\log\left(\frac{a^n}{n!}\right)=-k\log(10)$ yields $$ \bbox[5px,border:2px solid #C0A000]{n\sim ea\exp\left(\operatorname{W}\left(\frac k{ea}\log(10)-\frac1{2ea}\log(2\pi a)\right)\right)-\frac12}\tag{4} $$ For $k=1000$ and $a=100$, $(4)$ gives $1401.274188$