Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
This should be helpful in forming $\LaTeX$ expressions for you. – J. M. Sep 4 '11 at 9:52
Related... – J. M. Sep 4 '11 at 12:32
@Doug: I have formatted your question in $\LaTeX$. I suggest you look over the code so that you see how such equations are formatted. – mixedmath Sep 4 '11 at 15:04
Doug, should we add (English) words for you to select from, too?? – The Chaz 2.0 Sep 4 '11 at 15:18
@The Chaz Wow. You clearly do not understand why a website for math questions should have symbols to help aid the person asking a question. I do not even think you realize how it is very appropriate for a website like this to have the math symbols when posting a question. – Doug Sep 5 '11 at 7:59
up vote 14 down vote accepted

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

share|cite|improve this answer
Shouldn't it be n+(1/2)? in the first part of: (n−(1/2))logn−n+(1/2)log(2π). And what does taking the log of stirling's approximation mean? I honestly am a little bit unclear with logs when trying to isolate n. Could you show me step by step how to do that? – Doug Sep 4 '11 at 9:27
@Doug: you're right. Gerry, I hope you don't mind that I fixed your sign slip. – J. M. Sep 4 '11 at 9:35
I just added my attempt, hopefully someone can give me a hand. Also, should I start a new question for explanation of what is the log actually doing? – Doug Sep 4 '11 at 9:41
Thanks for fixing the sign. I made another mistake, writing $r$ where I needed $\log r$ at the end. I'll fix that one. Doug, all the log is doing is making the problem look a little nicer. You can't isolate $n$; what you can do, as I said, is use Newton's Method, which you can look up. Newton's Method uses Calculus. If you haven't done Calculus yet, you could start by seeing how close $n=\log r/\log\log r$ is to a solution, and then go a little higher or lower as necessary. – Gerry Myerson Sep 4 '11 at 12:31

$\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)$.

share|cite|improve this answer
a better approximation involving $W$ as well : – Stéphane Laurent Apr 25 '15 at 10:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.