6

This is simple factorial equation question.

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

(Edit)

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

For example,

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

jimjim
  • 9,855
Hanasima
  • 61
  • 1
  • 3
  • Well, did you try computing $5!,6!,7!$? – Pedro Oct 05 '13 at 23:26
  • 4
    I want to find a logical steps to find the n, other than brute force way. – Hanasima Oct 05 '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. – jimjim Oct 05 '13 at 23:31
  • 1
    @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 Oct 05 '13 at 23:32
  • 2
    @Hanasima: The brute force way is plenty logical. No sense trying to make an easy problem hard! –  Oct 05 '13 at 23:34
  • http://math.stackexchange.com/questions/171882/is-there-a-way-to-reverse-factorials?rq=1 – jimjim Oct 05 '13 at 23:35
  • @PedroTamaroff, thanks, and I think I should reiterate the question. That is not what I want. – Hanasima Oct 05 '13 at 23:38
  • The largest $n$ so that $n! < 10^{64}$ is also relatively easy by brute force. What is it that you are actually trying to do that you want this? If you could explain that, then people could give you responses that could help you do what you're actually trying to do. (which may include explaining why the approach you've taken is not the best way to go about it) –  Oct 05 '13 at 23:49
  • @Hanasima : I think what you are really interested in is the stirlings approximation for the $\Gamma$ function, the factorial and $\Gamma$ function are pretty mush the same for $n\geq 0$ – jimjim Oct 05 '13 at 23:53
  • @Hurkyl, what I want is to find the largest n for n!<k, k is very large number, which is not easy to get by brute force way. – Hanasima Oct 05 '13 at 23:54
  • @Arjang, yeah, probably. So, I'm reading the wiki how I can use it. – Hanasima Oct 05 '13 at 23:55
  • @Hanasima: $10^{64}$ is nowhere near the point where the problem has gone beyond "easy to get by brute force way". e.g. just about the simplest python program to do this completes in 0.05 seconds. –  Oct 06 '13 at 00:01

3 Answers3

6

If you are looking for non brute force methods of dealing with factorials, then probably what you want is Stirling's approximation: http://en.wikipedia.org/wiki/Stirling%27s_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.

Glorfindel
  • 4,000
3

There is a table of the first factorials at http://www.tsm-resources.com/alists/fact.html that can help you.

marty cohen
  • 110,450
0

50! = 3.0414 x 10^64 Factorials are defined for positive integers. Stirling's formula happens to give excellent results for factorials (n=positive integer). But it also works for positive non-integers. However, non-integers aren't factorials. It's interesting that 0! is defined as being equal to 1. This is necessary for calculating probabilities.

Greg Schaffer