# 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.

-
– Michael Lugo Oct 30 '10 at 1:12
Portuguese is not that hard to read, at least if you know French and/or Spanish, which are languages more commonly known to speakers of English. That being said, the meta.mathoverflow discussion on posting in non-English posts: tea.mathoverflow.net/discussion/142/nonenglish-posts. (The consensus there was that posts in all languages should be allowed, but there would probably be few non-English posts.) – Michael Lugo Oct 30 '10 at 1:29
-1: uninformative title – Jyotirmoy Bhattacharya Oct 30 '10 at 11:39
@Jyotirmoy, @Jason: I've edited the title. – Jonas Meyer Oct 30 '10 at 15:14
I once tried to solve this problem, but got nowhere... :( – Byron Schmuland Oct 30 '10 at 15:43

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.

-
I wonder if an attack along these lines might work for saying "there are no counterexamples below n" for sufficiently large n? – J. M. Oct 30 '10 at 10:57
@J.M. That's an interesting thought. – Derek Jennings Oct 30 '10 at 14:59

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

-
Prof. Elkies: I saw this last night on MO. Thanks very much! – Byron Schmuland Aug 26 '11 at 14:33

My numerical work and computing skills are not to be trusted, but the first "near miss" that I recorded was $n=252544447$.

-
Dear Byron Schmuland, Do you think you have found a counterexample? Thank you for your attention. – Paulo Argolo Nov 2 '10 at 14:33
@Paulo: "near miss" - so not really a counterexample. It might however give clues into what a true counterexample looks like. – J. M. Nov 2 '10 at 14:57
– Byron Schmuland Nov 5 '10 at 15:22