Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives

Calculating N Factorial

Date: 10/26/1999 at 11:42:06
From: Charles R.
Subject: Pauli exclusion principle and n! 

When one calculates n!, is there a method to do so quickly and exactly 
without crunching all intermediate factors? For example, when summing 
all numbers 1 + 2 + 3 + ... + n, one can either add all numbers from 1 
to n or one can apply hte formula [(n+1)*(n/2)] to find the answer 
without too much effort. Can this be done for n!?

Specific examples:

     = (100+1)(100/2)
     = 101*50
     = 5050

     = (shortcut formula?)
     = 3628800

I've run across the Stirling approximation formulas, but they're just 
not sufficiently exact (predictably enough.) Granted, the inaccuracy 
drops off to an infinitesimally small percentage of the answer (say, 
1% or 2% for n ~= 100), but when comparing the logarithms, there's 
still an inaccuracy of several percent for extremely large numbers (1% 
or 2% of the log for n ~= 10^100.)

I've also run across Simpson's Rule, but I must have gone at this one 
too many times because I can't see how it applies to this at all (at 
least not in any way to make matters easier and more concise.) The 
Gamma function offers nothing more than (n-1)! and that's not really 
any kind of help.

Charles Rockafellor

Date: 10/27/1999 at 17:25:22
From: Doctor Mitteldorf
Subject: Re: Pauli exclusion principle and n! 

Hi Charles!

Stirling's approximation is what you want.

The formula is sqrt(2pi*n)*(n^n)*e^(-n). It's much better than one 
percent accurate when calculating the log of the factorial of a large 
number. This formula is only the first term (or two) in a series in 
which higher order terms can provide whatever accuracy is desired. My 
guess, though, is that you did not include the Sqrt(2pi n) term in 
calculating the log, as this term is generally neglected in the 
formula for the log when n is REALLY huge.

- Doctor Mitteldorf, The Math Forum
Associated Topics:
College Number Theory

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:


parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]


Ask Dr. MathTM
© 1994-2015 The Math Forum