Solution (source code)

= Solution

The logarithm turns the product defining the <factorial> into $\ln(N!)=\sum_{k=2}^N\ln k$. Since $\ln x$ is increasing, each term bounds integrals on its adjacent unit intervals:
$$
\int_{k-1}^k\ln x\,dx\leq\ln k\leq\int_k^{k+1}\ln x\,dx.
$$
Summing from $k=2$ to $N$ proves the <integral bounds for a logarithmic factorial>:
$$
\boxed{N\ln N-N+1\leq\ln(N!)\leq(N+1)\ln(N+1)-N+1-2\ln2.}
$$
For $N=1$, both sides and the empty sum are zero. For $N\geq2$, the rectangle diagram gives the same inequalities geometrically. These bounds establish the leading $N\ln N-N$ growth, while <Stirling's formula> gives finer corrections.

\Image[/past-exam-of-the-mathematics-course-of-the-year-1-of-the-natural-sciences-course-of-the-university-of-cambridge/2005/paper-1-factorial-integral-bounds.png]
{title=Unit rectangles bound the logarithm of a factorial between two integrals}
{description=Original example with $N=6$. Left: each right-endpoint rectangle lies above $\ln x$ on $[k-1,k]$. Right: the same rectangle heights shifted to $[k,k+1]$ lie below $\ln x$. Both rectangle totals equal $\ln(6!)$.}