How to find $n \in \mathbb{N}$ such that, for some $m \in \mathbb{N}$, $n!$ is the largest factorial less than or equal to $m$

150 Views Asked by At

Say I have some natural number $m$. I want to find the natural number $n$ with the property that $n!$ is the largest factorial less than $m$. For instance, if $m = 17$, then $n = 3$ since $3! = 6$ but $4! = 24$. Is there an elegant way to do that?

1

There are 1 best solutions below

0
On BEST ANSWER

$n!=\Gamma(n+1)$

As $n\to +\infty$ we have $$\Gamma(n+1)\sim e^{-n} n^n \left(\sqrt{2 \pi n}+\frac{1}{6} \sqrt{\frac{\pi }{2 n}}\right)$$

Thus if we want $n$ such that $n!<10^6$ we solve numerically $$ e^{-n} n^n \left(\sqrt{2 \pi n}+\frac{1}{6} \sqrt{\frac{\pi }{2 n}}\right)=10^{20}$$ $n\approx 21.2185$. Take $\lfloor n \rfloor=21$

Indeed $21!\approx 5.1\times 10^{19}<10^{20}$