The other day, I found myself wondering how big 52! (52 factorial) is, and that led me to ponder how these could be estimated without a calculator or a computer. It turns out there’s some fairly interesting math behind being able to estimate the size (number of digits) of a factorial reasonably accurately. This post will start by stating how to do the estimate, and if you’re curious you can read on for the math background. Without further ado, the approximation is: As an example, let’s use my original question, by estimating this for 52! Well, 52 divided by is... 20-ish? And is about 1.3 [1]; therefore our estimate comes out to: The real answer is 68, so this is very close! In estimates like this - when you’re dealing with enormous numbers - being off by a couple of digits usually isn't a big deal. The Gamma function The Gamma function for real is defined [2] as: This integral does not have an analytic expression in the general case, but it does have a very useful property that we can take advantage of. Let’s see what is: And now use integration by parts with: Then: So: But notice that the last integral is just ; therefore, we’ve shown that: Let’s also calculate - it’s a special case that has an analytical solution: This helps establish an induction argument: In other words - the Gamma function is an interpolation of the factorial over all positive reals. Here’s a plot of the Gamma function over a small range; note that the y axis is log-scale because of the function’s fast growth: Stirling’s approximation You may have encountered Stirling’s approximation before: It’s a great approximation that works reasonably well even for small . This section is a brief overview of how Stirling’s formula is derived from the Gamma function. Taking: We’ll start by massaging the integrand a bit: And making a change of variables , which means that : These steps make the integral amenable to applying Laplace’s method, which allows us to approximate definite integrals of the...

How Big Are Factorials?
3 min read

