Estimating the Size of Huge Factorials

Factorials grow astonishingly fast. 52! is a number with 68 digits, and even rough estimates of its magnitude are surprisingly useful. You can estimate the number of digits in a factorial without a calculator using a straightforward approximation:

For 52!, the estimate works out to about 67 or 68 digits, which matches the exact value. When dealing with numbers this large, being off by a digit or two is usually irrelevant. The approximation is built on two pieces of mathematics worth understanding: the Gamma function and Stirling’s approximation.

The Gamma Function: Extending Factorials to Reals

The Gamma function is defined for real x as an integral that has no general analytic solution. However, it has a crucial recurrence property. By applying integration by parts, one can show:

This demonstrates that Γ(x+1) = x Γ(x). Combined with the special case Γ(1) = 1, an induction argument gives:

This means the Gamma function is an interpolation of the factorial over all positive reals. A plot of the Gamma function over a small range shows its rapid growth on a log scale:

Gamma function plot

Stirling’s Approximation

Stirling’s approximation is a well-known formula that estimates factorials with good accuracy even for small values:

n

Deriving it from the Gamma function starts with the integral definition. After a change of variables, the integrand takes a form suitable for Laplace’s method, which approximates integrals of the shape:

f(x)

where n is a large parameter and x_0 is twice-differentiable. Laplace’s method gives:

with f(x) being the global maximum of x_0=1.

Applying this to the Gamma function involves setting f(t) = ln(t) - t. This function is twice differentiable with a global maximum at n. Substituting the needed derivatives into Laplace’s approximation produces Stirling’s formula exactly.

Counting Digits from Stirling’s Formula

To estimate the number of digits in n!, take the base-10 logarithm of Stirling’s approximation:

The correction term in the logarithm is not multiplied by n itself, so its relative importance shrinks as n grows. Still, it contributes a few digits and should be kept for better accuracy.