Stirling's approximation


Stirling's approximation is an asymptotic approximation of a factorial, or more generally of the Gamma function. It reads

lnn!=nlnnn+O(lnn)\ln n! =n\ln n-n+O(\ln n)

using big-O notation. It can be written more precisely as

lnn!=nlnnn+12ln(2πn)+O(1n)\ln n! =n\ln n-n+ \frac{1}{2}\ln(2\pi n)+O\left( \frac{1}{n} \right)

and from this the factorial itself can be approximated as

n!2πn(ne)nn! \sim \sqrt{ 2\pi n } \left( \frac{n}{e} \right)^{n}