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

This is simple factorial equation question.

How do you find the largest n satisfying n! < 1000?


Actually, I want to find some other logic other than brute force.

For example,

How about the largest n for $n!<10^{64}$?

share|cite|improve this question
Well, did you try computing $5!,6!,7!$? – Pedro Tamaroff Oct 5 '13 at 23:26
I want to find a logical steps to find the n, other than brute force way. – Hanasima Oct 5 '13 at 23:30
@Hanasima, you are on the right path. only if there was an inverse factorial or inverse $\Gamma$ function this question would have been easy. – Arjang Oct 5 '13 at 23:31
@Hanasima Well, $n!>2^n$ if $n>4$, and $2^{10}=1024$, so you can look at $n=1,2,3,4,5,6,7,8,9$. Is that good enough? It isn't really brute forcing. One the other hand $6!=720$ so clearly...? Have you never computed a Taylor series up to the $6$th term? :) – Pedro Tamaroff Oct 5 '13 at 23:32
@Hanasima: The brute force way is plenty logical. No sense trying to make an easy problem hard! – Hurkyl Oct 5 '13 at 23:34

If you are looking for non brute force methods of dealing with factorials, then probably what you want is Stirling's approximation:

However, this approximation is really only helpful for large $n$; in your case, I'd say brute force is the best option.

Personally, I recall that $5! = 120$, after which $6! = 720$, and you know $7! > 1000$.

In response to the edit: To consider when $n!$ exceeds $10^{64}$ is to consider when $n!$ has at least sixty four digits; this sort of question can be broached using Stirling's Approximation combined with a base-$10$ log. Probably you could work this out yourself, but for more details, see here.

share|cite|improve this answer
Thanks. Now, I'm looking how to use the approximation to solve the original example. – Hanasima Oct 5 '13 at 23:50
@Hanasima: Okay, I have added additional details for your subsequent edit. – Benjamin Dickman Oct 6 '13 at 2:52

There is a table of the first factorials at that can help you.

share|cite|improve this answer
that is the same as brute force, isn't there an inverse factorial function somewhere? – Arjang Oct 5 '13 at 23:33
@Arjang That table is the "inverse factorial function" (for natural numbers at least). – Pedro Tamaroff Oct 5 '13 at 23:35
You can get good approximations by inverting Stirling's theorem, but there will always be problems near a large factorial $\pm 1$. – marty cohen Oct 5 '13 at 23:36
Thanks for the link. It would be helpful to find n for upto a certain number. – Hanasima Oct 5 '13 at 23:50

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.