Stirling's Approximation

n! ≈ √(2πn)(n/e)ⁿ — one of the most useful asymptotic formulas in mathematics. The relative error vanishes as n→∞, yet the absolute error diverges!

Stirling: ln(n!) ≈ n·ln(n) − n + ½·ln(2πn)
Relative error: |n! − S(n)| / n! → 0 as n → ∞
Next term: + 1/(12n) − 1/(360n³) + ...
n max: 60
nn!Stirling S(n)S2(n) +1/12nRel. error SRel. error S2