What function approximates the growth in length of factorial?

548 Views Asked by At

The factorial function grows in length in digits faster and faster. For example, early on it is multiplied by tens, so grows one or two digits each time. Then in the hundreds it grows two or three digits at a time, and so on. But the hundreds go on for longer than the tens, and the thousands go on longer still. Sorry for the quality of my description, but I hope you get what I mean.

Is the growth in length in digits of the factorial function exponential? Or something sub-exponential?

Please note, I am not talking about the growth in value of the factorial, but its growth in length in decimal digits. So 7! = 5040 which has 4 digits.

2

There are 2 best solutions below

4
On

By Stirling's approximation, we have $$ \ln(n!) \approx n \ln(n) - n $$ In particular, the number of digits in $n!$ is given by $\lfloor \log_{10}(n!) \rfloor$, and we have $$ \lfloor \log_{10}(n!) \rfloor = \left\lfloor\frac 1{\ln(10)}\ln(n!) \right\rfloor \approx \frac 1{\ln(10)}\left(n \ln(n) - n\right) = O(n \ln(n)) $$ So, the growth of the number of digits is subexponential, and faster than linear growth.

0
On

Do you mean the number of digits? The number of digits in $n!$ is the smallest integer which is strictly larger than $\log_{10}(n!)$. (This is slightly different from the integer ceiling function, since for instance $\log_{10}(10)=1$ but 10 has two digits.) This logarithm is the same as $\frac{\ln(n!)}{\ln(10)}$. By Stirling's formula this is asymptotically equivalent to $\frac{\frac{\ln(2 \pi)}{2} + \frac{\ln(n)}{2} + n \ln(n) - n}{\ln(10)}$.

As an example, 100! should have about $\frac{\frac{\ln(2 \pi)}{2} + \frac{\ln(100)}{2} + 100 \ln(100) - 100}{\ln(10)}$ digits, which rounds up to 158. It actually has 158 digits. Note that without the first two terms, which are the smaller ones, the answer you get is 157, which is still close.