# How the Mathematical Ninja estimates factorials

“I suppose,” said the Mathematical Ninja, “I can allow you to put $20!$ into a calculator. There’s absolutely no reason you should know that it turns out to be about $2.4 \times 10^{18}$.”

The student tapped the numbers in, frowned, thought for a moment and said “OK, I’ll bite. How…?”

“Simply Stirling’s approximation!” said the Mathematical Ninja, looking for all the world like someone who had left their favourite weapon of mass destruction outside in the car park ((There was, as it turned out, a reason for this.))

“Stirling’s approximation?”

“Stirling’s approximation,” confirmed the Mathematical Ninja, patiently. “ $n! \approx \sqrt{2\pi n} \left(\frac n e\right)^n$.”

Eyes left. Eyes right. “I have to confess,” confessed the student, “I don’t see how that makes it much easier.”

A big sigh. A glance towards the car park. If the Mathematical Ninja had been allowed to stand in the Labour leadership election, there would have been no questions about pressing the button ((Perhaps that’s why the Mathematical Ninja wasn’t allowed to stand.)). “Well, 20 is a tiny bit – about 0.4% – more than $e^3$, so the bracket is $\left(e^2\right)^{20}$, or $e^{40}$. In fact, I adjusted that, too – $0.4% \times 20$ is 8%, which I’ll need to add on at the end.”

Shrug. “I can sort of see that.”

“$2\pi (20)$ is $40π$, of course, which is about $\frac{880}{7}$, or roughly 126. The square root of that is a smidge more than 11.”

“Now you’re just showing off.”

The Mathematical Ninja continued, looking around for the car keys. “To turn $e^n$ into powers of ten, you divide $n$ by 2.3, and $\frac{40}{2.3} = \frac{160}{9.2} \approx 16$ (plus 8%), or about 17.3.”

“Oh, and you have a log trick, don’t you?”

“It’s not *mine*. I just cover it. That’s $2 \times 10^{17}$, because $\log_{10}(2) \approx 0.3$.”

“Then you multiply that by 11 to get a bit more than $2 \times 10^{18}$?”

“Call it $2.2 \times 10^{18}$! But I need to add 8% on to the number part. Eight percent of 2.2 is…”

“$0.176$!” said the student, brightly.

Nod. “Call it 0.2, which makes it $2.4 \times 10^{18}$.”

“And that’s the right answer!”

The Mathematical Ninja somehow mimed a mushroom cloud. “Boom!” The chuckle was just the right side of maniacal.