I am interested in good integer approximation from below and from above for binary Log(N!). The question and the question provides only a general idea but not exact values.
In other words I need integers A and B so that A <= Log(N!) <= B
2026-04-09 17:06:56.1775754416
On
How many bits are in factorial?
3.3k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
1
On
Expanding on joriki's answer, taking more terms from the approximation, $$ \log (n!) = n(\log n - \log e) + \frac{1}{2}\log n + \log \sqrt{2\pi} + \frac{\log e}{C_ n}, \quad 12n < C_n < 12n+1. $$ The number of binary digits is equal to $\lceil \log n! \rceil$, and for most $n$, I expect that the slight uncertainty in $C_n$ won't effect $\lceil \log n! \rceil$.
The Wikipedia article on Stirling's approximation gives the bounds
$$\sqrt{2\pi}\ n^{n+1/2}\mathrm e^{-n} \le n! \le \mathrm e\ n^{n+1/2}\mathrm e^{-n}\;,$$
so with $g(n)=((n+\frac12)\log n-n)$ we have
$$ \lfloor (g(n)+\log\sqrt{2\pi})/\log2\rfloor\le d(n)-1\le\lfloor (g(n)+1)/\log2\rfloor\;, $$
where $d(n)$ is the number of binary digits of $n!$ before the binary point.