# How the Mathematical Ninja approximates factorials, revisited

“That @ColinTheMathmo chap had a blog post on Stirling’s approximation, too,” said the student, spotting a chance to move the lesson away from his disappointing mock exam results. “Used it to work out 52!”

“I saw it,” said the Mathematical Ninja, polishing his weaponry smugly. “It… wasn’t *bad*, exactly…”

“But you can do better?” scoffed the student. “Better than @ColinTheMathmo?”

“You are very lucky,” said the Mathematical Ninja evenly, “that I hold Dr Wright in such high esteem, or else you would likely have been hoisted above boiling water…”

“Held in high steam, yeah, I get it. Bring on the sums.”

“You are familiar with Stirling’s Approximation, having read both of the blog posts; $n! \approx \sqrt{2 \pi n} \left( \frac{n}{e} \right)^n$.”

“Obviously.”

“So, we can approximate 50! as $\sqrt{100\pi} \left( \frac{50}{e} \right)^{50}$.

“Yes.”

“And you know that $e^{25} \approx 7.2 \times 10^{10}$, as near as dammit.”

“Er… let’s pretend I do.”

“That means the $e^{50}$ on the bottom is $51.84 \times 10^{20}$, which I’ll call 52 for now. As for $50^{50}$, that’s easy enough: it’s $\frac{100^{50} }{2^{50}} \approx \frac{10^{100}}{10^{15}}$ – only that bottom is too large by about 12.5%.”

“So you could make the top 12.5% smaller?”

The Mathematical Ninja poured water into a cauldron with a meaningful glare.

“I mean, uh, the bottom is 9/8 of what it should be, so you need to make the top 1/9 smaller! Ahem.”

“So, we’ve got $\sqrt{100\pi} \frac{\frac{8}{9} \times 10^{85} }{52 \times 10^{20}}$.”

“And $\sqrt{100\pi}$ is about 18!” Had the student been a dog, he would have been wagging his tail.

“Mhm, although that’s an overestimate of about 1.5%.”

“Picky.”

“So we’ve got roughly $\frac{16}{52} \times 10^{65}$ (less 1.5%.)”

The student nearly interrupted. “So then y… we need to multiply that by 51 and 52? Ah! And there’s a 52 on the bottom already!”

“Indeed! So we have $16 \times 51 \times 10^{65}$, less 1.5%.”

“That’s $816 \times 10^{65}$, and I need to take off about 12 before I juggle with the tens, making $8.04 \times 10^{67}$.”

“Ah, but the real answer is higher than that! What did we miss?”

“You mean what did I miss, presumably.”

“Indeed.”

The cauldron had gone off of the boil by now. The student took a risk. “I don’t know, what did I miss?”

“It’s not 52 on the bottom, but 51.84.”

“Silly me.”

“That means we’ve underestimated by 0.3%.”

“I won’t tell if you won’t.”

“So our actual answer is $8.06 \times 10^{67}$?”

“Give or take. Give or take.”

*Mainly for the benefit of @ColinTheMathmo: the mere mortals among us did $50! \approx 18 \times \left( \frac{10^{100}}{(52 \times 10^{20})(10^{15})}\right) = \frac{18}{52} \times 10^{65}$. Multiplying by 51 and 52 gave about $9 \times 10^{67}$, and the adjustment for $2^{10} \approx 10^3$ knocks it down to $8\times 10^{67}$. Thanks to @ColinTheMathmo and @DragonDodo for helping to clarify my thinking.*