惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
博客园_首页
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
博客园 - 聂微东
The Cloudflare Blog
小众软件
小众软件
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
H
Help Net Security
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享

Eli Bendersky's website

Concurrent Servers: Part 8 - Go Concurrent Servers: Part 7 - Rust Relative velocity and closing speed Notes on the Fourier Transform Dot product: Component vs. Geometric definition Summary of reading: April - June 2026 Plugins case study: Pluggy - Eli Bendersky's website Thoughts on starting new projects with LLM agents Notes on Fourier series Scaling, stretching and shifting sinusoids
How big are factorials? - Eli Bendersky's website
Eli Bendersky · 2026-08-28 · via Eli Bendersky's website

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:

Gamma function plot

Stirling’s approximation

You may have encountered Stirling’s approximation before:

It’s a great approximation that works reasonably well even for small n. 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 form:

Where f(x) is a twice-differentiable function and n some large number. By Laplace’s method, such integrals can be approximated by:

Where x_0 is the global maximum of f(x).

Let’s see how to apply this method [3] to the latest equation we have for (renaming the dummy integration variable back to ):

In our case, . It’s easy to show that this function is twice differentiable and has a global maximum at x_0=1. Moreover:

Substituting these into the proper places in Laplace’s approximation, we get:

Number of digits from Stirling’s approximation

We can calculate the number of digits in by taking the base-10 logarithm of Stirling’s formula:

Note that the first term is not multiplied by n itself; therefore, as n grows, it will become less and less noticeable. That said, it still adds a couple of digits - so you should take it into account if you want a more accurate approximation [4]


[1]Mental tricks for calculating is a different topic, but it really helps to remember that , , and from here using the various logarithm laws to estimate multiples.
[2]As a matter of fact, the Gamma function is defined for complex numbers, but for our purpose talking about the reals is sufficient.
[3]As much as I’d like to dive into why this approximation works, the rabbit hole in this post is already deep enough!
[4]It adds up to 2 extra digits as long as n is less than 1600 or so, and may add more than 2 after that, though no more than 3 until n is 160000. It’s not clear why anyone would like to estimate the number of digits of 1600! (about 4450, in case you were wondering), let alone 160000!