TAOCP 1.2.5 Exercise 5
Applying the refined form of Stirling’s approximation with $n=8$ gives 8!
Section 1.2.5: Permutations and Factorials
Exercise 5. [**] [15] Estimate $8!$ using the following more exact version of Stirling's approximation:
$$ n! \approx \sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(1+\frac{1}{12n}\right). $$
x 6. [17] Using Eq. (8), write $20!$ as a product of prime factors.
Verified: yes
Solve time: 37s
Applying the refined form of Stirling’s approximation with $n=8$ gives
$$ 8! \approx \sqrt{2\pi\cdot 8}\left(\frac{8}{e}\right)^8\left(1+\frac{1}{12\cdot 8}\right). $$
Since
$$ \sqrt{16\pi}=4\sqrt{\pi},\qquad \left(\frac{8}{e}\right)^8=2^{24}e^{-8}, \qquad 1+\frac{1}{96}=\frac{97}{96}, $$
we obtain
$$ 8!\approx 4\sqrt{\pi}\left(\frac{8}{e}\right)^8\frac{97}{96} =2^{26}\sqrt{\pi},e^{-8}\frac{97}{96}. $$
Using $\sqrt{\pi}\approx1.77245$ and $e^{-8}\approx0.00033546$,
$$ 8!\approx 67108864\cdot1.77245\cdot0.00033546\cdot\frac{97}{96} \approx 40318. $$
Since $8!=40320$ exactly, the estimate differs by only about $2$. Therefore
$$ \boxed{8!\approx 40318}. $$