Does Stirling's formula give the correct number of digits for $n!\phantom{}$?

It is known that the number of digits of a natural number $n > 0$, which represent by $d(n)$ is given by:

$d(n)= 1 + \lfloor\log n\rfloor\qquad (\text{I})$

($\log$ indicates $\log$ base $10$)

Well .. the classical approach to the Stirling factorial natural number $n > 1$ is given by:

$$n! \approx f(n) = [(2n\pi) ^{1/2}] [(n / e) ^ n]$$

The number of digits $n!$, according to equality (I), is:

$d(n!) = 1 + \lfloor\log n!\rfloor$

It seems to me that for all natural $n> 1$, $\log n!$ and $\log [f (n)]$ have the same floor:

$$\lfloor\log(n!)\rfloor = \lfloor\log(f(n))\rfloor$$

Here's my big question!

Therefore, we could write:

$$d (n!) = 1 + \lfloor\log(f(n))\rfloor$$

Hope someone has some little time for the theme.


6561101970383 is a counterexample, and the first such if I computed correctly. See my answer in https://mathoverflow.net/questions/19170 for more information.


Here are some thoughts on the conjecture that may lead one to suspect that it is true. This is not a proof that it is true.

We want to know whether

$$ \left\lfloor \log_{10} n! \right\rfloor = \left\lfloor \log_{10} \lfloor f(n) \rfloor \right\rfloor$$

is true for all $n > 1.$

We note that this would NOT be true if the interval $I_n = ( \log_{10} n!,\log_{10} \lfloor f(n) \rfloor)$ contains an integer but is true otherwise.

So let's look at the length of $I_n.$

From the Stirling series we have

$$\frac{1}{\log_{e}10} \left( \frac{1}{12n} - \frac{1}{360n^3} \right) < \log_{10} n! - \log_{10} f(n) < \frac{1}{\log_{e}10} \frac{1}{12n}.$$

And so taking the integer part of $f(n)$ we have

$$\frac{1}{\log_{e}10} \left( \frac{1}{12n} - \frac{1}{360n^3} \right) < \log_{10} n! - \log_{10} \lfloor f(n) \rfloor < \frac{1}{\log_{e}10} \left( \frac{1}{12n} + \frac{1}{ \lfloor f(n) \rfloor } \right),$$

where to achieve the RHS we note that

$$ \log_{10} f(n) - \log_{10} \lfloor f(n) \rfloor < \frac{1}{ \lfloor f(n) \rfloor \log_e 10 }.$$

Hence $$\text{Length}(I_n) < \frac{1}{\log_{e}10} \left( \frac{1}{360n^3} + \frac{1}{ \lfloor f(n) \rfloor } \right).$$

We can verify that the conjecture holds for $n=2,3,\ldots,10,$ so summing up the remaining lengths of the $I_n$ we have

$$\sum_{n=11}^\infty \text{Length}(I_n) < \frac{1}{360 \log_e 10} \left( \sum_{n=11}^\infty \frac{1}{n^3} + \sum_{n=11}^\infty \frac{1}{ \lfloor f(n) \rfloor } \right).$$

Now $ \lfloor f(n) \rfloor \ge (n-1)! $ and so, doing some calculations (replacing the $ \lfloor f(n) \rfloor $ on the RHS by $ (n-1)! $ , we have

$$\sum_{n=11}^\infty \text{Length}(I_n) < \frac{1}{360 \log_e 10} \left( 0.00452492 + 0.00000030 \right) < 5.5 \times 10^{-6}.$$

Hence the probability that an integer falls in any of the intervals is very small.