10
$\begingroup$

Is there a way to estimate how big $n!$ is for a certain $n$? For example, without using a calculator, what is the magnitude of $7!$ or $12!$ or $100!$?

$\endgroup$
4
  • 1
    $\begingroup$ If you have access to a computer, Wolfram Alpha tells you the number of digits. $\endgroup$
    – Justin
    May 7, 2014 at 16:40
  • $\begingroup$ @Quincunx That comes under calculator I think :D $\endgroup$
    – Sawarnik
    May 8, 2014 at 6:23
  • $\begingroup$ @Sawarnik Nah, Wolfram Alpha isn't a calculator. Wolfram Alpha is a "computational knowledge machine" $\endgroup$
    – Justin
    May 8, 2014 at 6:28
  • 3
    $\begingroup$ @Quincunx which are fancy words for "hella-big calculator" $\endgroup$
    – Darkhogg
    May 8, 2014 at 15:03

4 Answers 4

20
$\begingroup$

Yes, Stirling's formula:

\begin{equation} n! \; \sim \; \sqrt{2\pi n} \left(\frac{n}{e}\right)^n. \end{equation}

$\endgroup$
7
  • 11
    $\begingroup$ Additional thought to otherwise appropriate answer: if you don't have a calculator and want a numerical estimate, it's probably better to look at the base-10 logarithm of this. $\endgroup$
    – orion
    May 7, 2014 at 13:27
  • 11
    $\begingroup$ Any equation that includes both e and pi always looks like witchcraft to me. $\endgroup$ May 7, 2014 at 17:36
  • 2
    $\begingroup$ @mikeTheLiar Study complex analysis. There is no end to the witchcraft in that field. $\endgroup$ May 7, 2014 at 19:25
  • 3
    $\begingroup$ @Goos Alternatively, there is an immediate end to the witchcraft once you understand the relationship between exponents and angles. $\endgroup$ May 7, 2014 at 21:59
  • 1
    $\begingroup$ @KyleStrand I don't just mean the complex exponential. I mean the entire field of complex analysis. Maximum modulus principle, bounded entire function is constant, once-differentiable implies $C^\infty$, integration techniques, etcetera etcetera. Witchcraft. $\endgroup$ May 8, 2014 at 0:42
16
$\begingroup$

Another answer in this thread suggests Stirling's approximation: $$n! \approx \sqrt{2\pi n}\biggl(\frac ne\biggr)^n$$

which I think is the right place to start for any answer to this question. However, it may be useful to add that if you take the logarithm of this amount, you get the (approximate) number of digits you need to write down $n!$, which may be of more use:

$$\begin{align} \log n! & \approx \color{darkblue}{n\log n} - n\color{maroon}{\log e} + \color{darkblue}{\frac12 \log n} + \color{darkgreen}{\frac12\log 2\pi}\\ & \approx \color{darkblue}{\biggl(n+\frac12\biggr)\log n} - \color{maroon}{0.43}\cdot n + \color{darkgreen}{0.798} \end{align} $$

($\log$ here is the common, base-10 logarithm function.)

For small $n$ this gives the following values, which I have rounded off to the nearest integer:

$$\begin{array}{rr} n & \text{length of $n!$} \\\hline 1 & 0 \\ 2 & 1 \\ 3 & 1 \\ 4 & 2 \\ 5 & 2 \\ 6 & 3 \\ 7 & 4 \\ 8 & 5 \\ 9 & 6 \\ 10 & 7 \\ 11 & 8 \\ 12 & 9 \\ 13 & 10 \\ 14 & 11 \\ 15 & 13 \\ 16 & 14 \\ 17 & 15 \\ 18 & 16 \\ 19 & 18 \\ 20 & 19 \\ \end{array} $$

This is correct for all $n$ shown except $1$ and $5$, for which it is off by 1.

$\endgroup$
10
$\begingroup$

A cool alternative to Stirling's formula could be the more accurate formula derived by Srinivasa Ramanujan, $$ \ln(n!) \sim n\ln(n) - n + \frac{1}{6}\ln(n(1+4n(1+2n))) + \frac{1}{2}\ln(\pi). $$

$\endgroup$
4
  • 1
    $\begingroup$ But this is $log_e$, not $log_{10}$, which is what it seems the OP wants. $\endgroup$
    – Cole Tobin
    May 8, 2014 at 0:09
  • $\begingroup$ Sure, but it's fairly easy to convert between the two, just multiply the RHS by $\log_{10} \mathrm{e} \approx 0.4$ $\endgroup$ May 8, 2014 at 0:10
  • $\begingroup$ I don't know... Multiplication is pretty hard. </sarcasm> $\endgroup$
    – Cole Tobin
    May 8, 2014 at 0:11
  • 1
    $\begingroup$ You could of course use logs to do multiplication </oldfogey> In any case it becomes $\log_{10}(n!) \sim n\log_{10}(n) - n \log_{10}(e) + \frac{1}{6}\log_{10}(n(1+4n(1+2n))) + \frac{1}{2}\log_{10}(\pi).$ $\endgroup$
    – Henry
    May 8, 2014 at 9:45
4
$\begingroup$

A different tack here, as you I suspect you are asking for a method that doesn't require any 'advanced' functions.

How large a positive integer number is, can be expressed well in terms of how many digits it takes to write the number. This is best represented as the integer part of the logarithm of the number, plus 1 (logarithm base 10, i.e. Log not Ln). For example LOG[55] = 1.74 (2 d.p.), it requires INT[1.74] + 1 = 2 digits to represent it. You can get a better feel for the size of a number by looking at the digits after the decimal point in the logarithm too.

Doing polynomial fits of LOG[n!] vs n gives these two useful approximate working regions.

n = 7 to 119 (cubic polynomial): LOG[n!] ~ -0.0000284659105*n^3 + 0.00943671908*n^2 + 0.962859106*n - 3.95423829 Maximum error factor in range of 2.93

n = 120 to 1000 (5th order polynomial): LOG[n!] ~ -4.68977059E-13*n^5 + 0.00000000164012606*n^4 - 0.000002402405*n^3 + 0.0021512217*n^2 + 1.6770136*n - 29.6620872 Maximum error factor in range of 1.94

You could do better with higher order polynomials, particularly in range 7 to 119, but these are good enough to tell you "how big" the factorials are.

Below 7 you should be able to do in your head :-)

$\endgroup$
2
  • $\begingroup$ Yes, i Was looking for something like this. I Was surprised though, by the variety of answers... So i'm checking them aswell :) $\endgroup$
    – Trux
    May 8, 2014 at 4:28
  • $\begingroup$ An addition, I perhaps wasn't clear what the error factor was. This is the error in n!. So n! is within a factor of 2 across the full 120 to 1000 range, LOG[n!] is within +/-0.29. $\endgroup$ May 8, 2014 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .