Is there a way to solve for an unknown in a factorial?

19.8k Views Asked by At

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.

3

There are 3 best solutions below

4
On 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$.

2
On

$\exp(1+W(\log(n!)/e))-\frac{1}{2}\searrow n$ as $n\to\infty$where $W$ is the Lambert W function. For integer $n\ge2$, the floor is exact.

I just took the expansion out a bit more and the approximation I gave above overestimates $n$ by $\log\left(\sqrt{2\pi}\right)/\log(n)$.

0
On

I believe you can solve Sterling’s formula for $n$ by way of the Lambert $W$ function, but that just leads to another expression, which can not be directly evaluated with elementary operations. (Although, I wish scientific calculators included the Lambert $W$, at least the principal branch).

I’ve derived a formula which is moderately accurate. If you are rounding to integer values of $n$, it will provide exact results through $170!$, and perhaps further. The spreadsheet app on my iPad will not compute factorials beyond $170!$.

If you are seeking rational solutions for $n$, in other words, trying to calculate values of a sort of inverse Gamma function, it will provide reasonably close approximations for $n$ in $[2, 170]$, and as I remarked above, possibly greater.

My Clumsy Little Equation:

I also have derived a variant which is much more accurate for $n$ in $[2, 40\text{ish}]$, however it starts to diverge beyond that.

I initially derived these approximations for my daughter, who, while working on Taylor/Maclaurin series, wanted a quick way to check for potential factorial simplifications in the denominator of terms.

I couldn’t find any solutions, except the obvious path through Stirling’s formula and the Lambert $W$ function. If more competent mathematicians can find a tweak which can improve accuracy, please share it.

I apologize in advance, as I am new here (as a contributor, that is), and I am not yet allowed to directly embed an image. Hopefully, the linked one works.