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.