Stirling's approximation to the factorial is typically written as: \begin{eqnarray} n! & \approx & \sqrt{2 \pi n} \left(\frac{n}{e}\right)^n \end{eqnarray}
To find this approximation, we can begin with the observation that: \begin{eqnarray*} \ln(n!) & = & \ln(1 * 2 * 3 * \cdots * n) \\ & = & \ln(1) + \ln(2) + \ln(3) + \cdots + \ln(n)\\ & = & \sum_{i = 1}^{n}\ln ( i ) \end{eqnarray*}
There are various ways to approximate this sum, some more accurate than others, some
easier to compute than others.
One relatively straightforward way to approximate is to use integrals:
\begin{eqnarray*}
\ln (n !) & = & \sum_{i = 1}^{n}\ln ( i ) \\
& \approx & \int_1^n \ln(x) dx \\
& = & n \ln (n) - n + 1
\end{eqnarray*}
Exponentiating each side, we get the first approximation:
\begin{eqnarray*}
n ! & \approx & e^{n \ln (n) - n + 1} \\
& = & \left(e^{\ln(n)}\right)^n e^{-n}e \\
& = & n^n e^{-n} e \\
& = & e * \left(\frac{n}{e}\right) ^ n
\end{eqnarray*}
This is fairly rough, so in practice it makes sense to ignore
the factor of $e$ in front, and just use the approximation:
\begin{eqnarray*}
n ! & \approx & \left(\frac{n}{e}\right) ^ n
\end{eqnarray*}
This is good enough for a variety of uses $\ldots$
A more careful derivation of Stirling's approximation (including upper and lower bounds) using infinite series for logarithms instead of integrals follows: \begin{eqnarray*} \ln n! & = & n\ln\ n-\sum_{k=1}^{n-1} k\ln\left(1+\frac1k\right)\\ & = & n\ln n+\sum_{L=1}^\infty\left(\sum_{k=1}^{n-1}k(-1)^L\frac{k^{-L}}L\right)\\ & = & n\ln\ n-(n-1)+\frac12\sum_1^{n-1} k^{-1}-\frac13\sum_1^{n-1} k^{-2}+\dots\\ \end{eqnarray*}
Approximate $\sum k^{-1}$ using
$$\ln\ n = \sum_1^{n-1} \ln\left(1+\frac1k\right)=\sum_1^{n-1} k^{-1}-\frac12\sum_1^{n-1} k^{-2}+\dots$$
When we group according to powers of $k$ we get:
$$\ln\ n! = n\ln\ n-(n-1)+\frac12\ln\ n +\left(\frac14-\frac13\right)
\sum_1^{n-1} k^{-2}$$
$$+\left(-\frac16+\frac14\right)\sum_1^{n-1} k^{-3}+\dots$$
$$\hbox{Let:}\quad S=\left(n+\frac12\right)\ln n-(n-1)$$
$$M_L=\sum_{k=1}^\infty k^{-L}$$
$$M=\sum_{L=2}^\infty(-1)^L\left(\frac1{L+1}-\frac1{2L}\right) M_L$$
\begin{eqnarray*}
\ln n! & = & S-\frac1{12}\left(M_2-\sum_n^\infty k^{-2}\right) \\
& & -\sum_{L=3}^\infty(-1)^L\left(\frac1{L+1}-\frac1{2L}\right)\left(M_L-\sum_n^\infty k^{-L}\right)\\ & = & S-M+\frac1{12}\sum_n^\infty k^{-2}-\frac1{12}\sum_n^\infty k^{-3} \\
& & +\frac3{40}\sum_n^\infty k^{-4}-\frac1{15}\sum_n^\infty k^{-5}+\dots \\
\end{eqnarray*}
Since:
$$ \frac1{12k^2}-\frac1{12k^3}+\frac3{40k^4}=
\frac1{12}\left(\frac1k-\frac1{k+1}\right)-\frac{k-9}{120k^4(k+1)} ,$$
we have
$$S-M+\frac1{12n}-\sum_n^\infty\frac{k-9}{120k^4(k+1)} $$
$$> \ln\ n! >$$
$$ S-M+\frac1{12n}-\sum_n^\infty\frac{k-9}{120k^4(k+1)}
-\sum_n^\infty\frac1{15k^5}$$
For $n \ge 9$, $ \ln n! < S-M+1/12n$ is immediate. For a lower bound,
we can use $[k\ge9]$: $$\frac{k-9}{120k^4(k+1)}+\frac1{15k^5}=\frac{k^2-k+8}{120k^5(k+1)}$$
$$ < \frac1{120k^3(k+1)}<\frac1{360}\left(\frac1{(k-1)^3}-%
\frac1{k^3}\right)$$
to obtain $\ln n!>S-M+1/(12n)-1/(360(n-1)^3)$.
To determine $M$, the usual argument involving Wallis' product can be used: \begin{eqnarray*} \lim_{n\to\infty}\frac{4^n(n!)^2}{\sqrt{2n}(2n!)} & = & \lim\frac{2\cdot 4\cdot6\dots(2n-2)\sqrt{2n}}{3\cdot5\dots(2n-1)} \\ & = & \sqrt{\frac\pi2} \\ & = & e^{1-\ln 2-M} \\ \end{eqnarray*} So: $e^{-M}=\frac{\sqrt{2\pi}}e$