2

The factorial of $10^{100}$ is a huge number. I want to know how many decimal digits $_\#D$ this number has:

$$\\_\#D=\left \lfloor \log(10^{100}!)/\log(10) \right \rfloor+1 $$

Unfortunately I am getting an overflow error when using a computer program to solve it. Is it possible to determine the exact number of decimal digits of $\large 10^{100}!$?

jvdhooft
  • 7,589
  • 9
  • 25
  • 47
eddie
  • 21

5 Answers5

4

Yes, it is possible!

We know: $n!=\Gamma(n+1)$

so for the number of decimal digits of $n!$ we can write: $$\large D_{n!}=\left \lfloor log(\Gamma (n+1))/log(10) \right \rfloor+1 $$

we still won't be able to calculate $\Gamma (10^{100}+1)$, but there is a function that calculates the logarithm of the Gamma function directly : the Log-Gamma-Function. That is exactly what we need!

$$\large D_{n!}=\left \lfloor ln\Gamma (n+1)/log(10) \right \rfloor+1 $$

For example to calculate $D_{n!}$ in Pari/GP type:

\p 150
D(n)=floor(lngamma(n+1)/log(10))+1;
D(10^100)

which will give us the correct answer immediately:

$$\large D_{10^{100}!}=$$ $$\small 995657055180967481723488710810833949177056029941963334338855462168341353507911292252707750506615682568$$

a $102$ decimal digit number.

3

From Wikipedia on Stirling, you get that

$$\ln n!\approx n\ln n-n+\frac12\ln(2\pi n)$$ and the trunction error is at most $\dfrac1{12n}$.

Then

$$\log_{10}\left(10^{100}\right)!\approx\left(100-\frac1{\ln10}\right)10^{100}+\log_{10}\sqrt{2\pi}+50.$$

By rounding you will get the exact number, provided you can evaluate $\log_{10}e$ to $100$ decimals. OEIS provides just enough digits for you to compute by hand. https://oeis.org/A002285. The other log term is about $0.3991$.

https://www.wolframalpha.com/input/?i=ceil((100-1%2Fln(10))10%5E100%2B50%2B0.3991)

  • @Yves Daoust I don't think that your number is correct. It shoud be greater than $10^{100}\cdot 99.5$. – Robert Z Sep 29 '16 at 07:49
  • @RobertZ: my fixed answer now evaluates $99.565705518096748172348871081083\cdots10^{100}$. You are right. –  Sep 29 '16 at 07:53
2

We have that $$\left \lfloor \log(10^{100}!)/\log(10) \right \rfloor+1= \left \lfloor \log_{10}(10^{100}!) \right \rfloor+1.$$ Moreover by Factorial Inequality problem $\left(\frac n2\right)^n > n! > \left(\frac n3\right)^n$, $$10^{100}\cdot 99.7>10^{100}\left(100-\log_{10}2\right)>\log_{10}(10^{100}!) > \log_{10}\left(\frac{10^{100}}{3}\right)^{10^{100}}\\=10^{100}\left(100-\log_{10}3\right)>10^{100}\cdot 99.5$$ But this is only an estimate ...

I think that it is quite hard to determine the exact number of digits. For a more precise estimate you should use the inequalities due to Robbins given here: $$\sqrt{2\pi}n^{n+1/2}e^{-n}e^{1/(12n+1)}<n!< \sqrt{2\pi}n^{n+1/2}e^{-n}e^{1/(12n)}.$$

Robert Z
  • 145,942
2

One can tackle the question quite directly: $$ \log_{10}\left(10^{100} !\right)=\log_{10}\left(\prod_{l=1}^{10^{100}}l\right) $$ and then ordering the terms by magnitude $$ = \log_{10}\left(\prod_{k=1}^{100} \left(\prod_{m=10^{(k-1)} +1}^{10^k} m \right)\right) $$ gives us $$ = \sum_{k=1}^{100}\left(\sum_{m=10^{(k-1)} + 1}^{10^k} \log_{10}\left(m\right)\right) $$ where we can estimate $(k-1) < \log_{10}\left(m\right) \le k$. We then arrive at the estimate $$ \sum_{k=1}^{100} \left(10^k - 10^{(k-1)} -1 + 1\right)\left(k-1\right) < \log_{10}\left(10^{100}!\right) \le \sum_{k=1}^{100} \left(10^k - 10^{(k-1)} -1 + 1\right)k $$ and finally noticing that $10^k - 10^{k-1}=9\cdot10^{k-1}$ we get the estimate $$ \sum_{k=1}^{100} 9\cdot 10^{(k-1)} \left(k-1\right) < \log_{10}\left(10^{100}!\right) \le \sum_{k=1}^{100} 9\cdot 10^{(k-1)}k. $$ Calculating the bounds, we get $$ 9.889\cdot 10^{101} < \log_{10}\left(10^{100}\right) \le 9.989\cdot 10^{101} $$ Furthermore, from a quick numerical estimate it appears that one can get a lot better estimate than $(k-1) < \log_{10}\left(m\right) \le k$ above and obtain a lot sharper estimate, in particular the error relative to the width of the estimate seems to go to a constant value.

yoshi
  • 148
1

Another way to estimate:

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

$$n!\approx (2\pi n)^{1/2}n^ne^{-n}$$

to approximate the number of digits.

Now, $\left(2\pi 10^{100}\right)^{1/2}\approx 10^{50}$ and $n^ne^{-n}=(10^{100}/e)^{ 10^{100}}\approx 10^{99\cdot10^{100}}\approx 10^{10^{102}}$, so we have that

$$10^{100}!\approx 10^{50}\cdot 10^{10^{102}}= 10^{50+10^{102}}\approx 10^{10^{102}}$$

The number of digits of this number is $\log_{10}10^{10^{102}}=10^{102}$.

Alex
  • 848