Quant Memo
Core

Stirling's Approximation in Puzzles

A formula that approximates the fast-growing factorial function using elementary terms, giving interview candidates a quick way to estimate huge combinatorial quantities by hand.

Computing something like "how many ways can you shuffle 52 cards" or estimating a binomial coefficient with large numbers means dealing with factorials, which grow so fast that exact computation by hand is impractical and even a calculator's output is hard to interpret intuitively. Stirling's approximation gives a simple estimate: n!2πn(n/e)nn! \approx \sqrt{2\pi n}\,(n/e)^n, which becomes very accurate as nn gets large. In plain terms, a factorial's size is dominated by nn raised to roughly its own power divided by ee, with a modest correction factor out front.

In an interview setting, candidates rarely need the full formula — the key trick is the simplified log version: ln(n!)nlnnn\ln(n!) \approx n\ln n - n. This lets you estimate things like the order of magnitude of 100!100! mentally: ln(100!)100ln100100100(4.6)100=360\ln(100!) \approx 100\ln100 - 100 \approx 100(4.6) - 100 = 360, so 100!e360100! \approx e^{360}, an astronomically large number confirmed to be roughly correct order-of-magnitude without ever multiplying 100 numbers together. This kind of quick estimation is exactly what interviewers probing for numerical intuition are testing.

Stirling's approximation, n!2πn(n/e)nn! \approx \sqrt{2\pi n}(n/e)^n, or its simpler log form ln(n!)nlnnn\ln(n!) \approx n\ln n - n, lets you estimate the size of huge factorials or combinatorial counts by hand instead of needing exact multiplication.

Related concepts

Practice in interviews

Further reading

  • Feller, An Introduction to Probability Theory, vol. 1, ch. 2
ShareTwitterLinkedIn