I don't want to do this through trial and error, and the best way I have found so far was to start dividing from 1.
$n! = \text {a really big number}$
Ex. $n! = 9999999$
Is there a way to approximate n or solve for n through a formula of some sort?
Update (Here is my attempt):
Stirling's Approximation: $$n! \approx \sqrt{2 \pi n} \left( \dfrac{n}{e} \right ) ^ n$$
So taking the log:
$(2\cdot \pi\cdot n)^{1/2} \cdot n^n \cdot e^{-n}$
$(2\cdot \pi)^{1/2} \cdot n^{1/2} \cdot n^n \cdot e^{-n}$
$.5\log (2\pi) + .5\log n + n\log n \cdot -n \log e$
$.5\log (2\pi) + \log n(.5+n) – n$
Now to solve for n:
$.5\log (2\pi) + \log n(.5+n) – n = r$
$\log n(.5+n) – n = r – .5 \log (2\pi)$
Now I am a little caught up here.
Best Answer
A good approximation for $n!$ is that of Stirling: $n!$ is approximately $n^ne^{-n}\sqrt{2\pi n}$. So if $n!=r$, where $r$ stands for "really large number," then, taking logs, you get $\left(n+\frac12\right)\log n-n+\frac12\log(2\pi)$ is approximately $\log r$. Now you can use Newton's method to solve $\left(n+\frac12\right)\log n-n+\frac12\log(2\pi)=\log r$ for $n$.