# Solving $n! = 10^6$ for $n$

I am trying to solve $$n! = 10^6$$ for $$n$$. I thought to do this using the gamma function:

$$(n - 1)! = \Gamma(n) = \int_0^\infty x^{n - 1}e^{-x} \ dx$$

So I have that

$$\Gamma(n + 1) = \int_0^\infty x^n e^{-x} \ dx = 10^6$$

I thought to solve this using integration by parts:

\begin{align} \Gamma(n + 1) &= \int_0^\infty x^n e^{-x} \ dx \\ &= [-x^n e^{-x}]^{\infty}_0 + \int_0^{\infty} nx^{n - 1}e^{-x} \ dx \end{align}

But, as you can see, unless I have made a mistake, we get the term $$\int_0^{\infty} nx^{n - 1}e^{-x} \ dx$$, which, as far as I can tell, means that we get stuck in an infinite loop of integration by parts.

So how do I solve this?

Thank you.

• There is no such natural number $n$, because if $n!$ is divisible by $5$, then it must be divisible by $3$. If you solve $\Gamma(x + 1) = 10^6$, then a real solution should exist, but it won't be an integer. Is this what you want? – user754697 Mar 4 '20 at 4:52
• Are you sure that is the equation you want? $10^6=2^65^6$ only has prime factors $2$ and $5$, but $n!$ is divisible by $3$ for all $n\geq 3$. – Dave Mar 4 '20 at 4:53
• @user754697 To reply to you both, I am solving a computational (time) complexity problem from my textbook. It says that $n! = 10^6$, where we have $10^6$ microseconds in a second, means that $n = 9$. Does that clarify things? – Dom Fomello Mar 4 '20 at 4:55
• This is WolframAlpha's calculation: wolframalpha.com/input/?i=n%21+%3D+10%5E6 – Dom Fomello Mar 4 '20 at 4:59

Applied to your case $$n! =y$$it write
$$n \sim \frac{{\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right)}} -\frac{1}{2}$$ and, for $$y=10^6$$, it will give $$n=9.44379$$ while the exact solution is $$9.44561$$.
Using WolframAlpha, I get $$n=9.4456089144163262435935599652$$, but thats about as far as I can figure. There's not really a good way to reverse the Gamma function to solve something like that besides numerical approximations.