From the standpoint of a number theorist, Stirling's formula is a significantly inaccurate estimate of the factorial function (n! = 1*2*3*...*(n-1)*(n)). The formula is:

n! ~ (n/e)n

There are a couple ways of deriving this result. One is to use the Euler Gamma function; take the derivative of the functional portion of the integral, then work from there. Another is to use the natural logarithm directly:

ln(n!) = ln (n*(n-1)*(n-2)*...*2*1) = ln n + ln (n-1) + ... + ln 2 + ln 1.

This is not an approximation, but it is also functionally equivalent to computing n! directly, so it is equally useless. However:

           n           / n
         -----        /
         \           |
ln(n!) =  > ln(i) ~   \   ln(x)dx = nln(n)-n+1.
         /             |
         -----        /
          i=1        / 1

eln(n!)=n!, so n! ~ enln(n)-n+1=e*(n/e)n. We leave off the 1 because, as n approaches infinity, the 1 "becomes insignificant". For small values of n, the formula is wildly inaccurate regardless of whether the 1 is present.

Why on earth would I want to use this? n! can be calculated directly, right?

True. For small values of n, the best way to get n! is to calculate it directly. But what does it mean for n to be "small"? That probably depends on the computing equipment at hand. Is it particularly time intensive to calculate 300!? 3000!? 3000000!? How about 1040!?

As of the timestamp of this writing, the largest known prime number is the Mersenne prime 213,466,917-1, which has roughly 4 million decimal digits. From Wilson's theorem, the fastest way to check if a number is prime might be to use the congruence -1=(n-1)! (mod n) (since there is only one test involved). So, can your TI-89 calculate the value of (213,466,917-2)!? I wish it could. Because of the sheer size of the numbers involved, an approximation of n! would be very nice to have, if only it were more accurate. Another significant block in the usage of this formula is the computational accuracy of the number e. nn is relatively easy, but en=1+n+(n2)/2!+(n3)/3!+... is not accurate at the integer level before the nth term (nn)/n! (nor for quite a distance after), which involves the value in question. Thus, as it stands, Stirling's formula is merely of passing interest in number theory.

Note: the formula that krimson states is the "real" formula that Stirling proposed; it's an approximation given by truncating all but the first term of the Stirling Series (see, where other even closer approximations are given). The point of my writing here is to make people aware of how useful the formula is in other contexts.