Given a number like $10^{20}!$, what can I, in a reasonable amount of time, figure out about it? Can I figure out how many digits it has, and/or what the first digit is? I found Striling's approximation, but I'm not aware of a realistic way to calculate something raised to the nth where n = $10^{20}$
2026-04-09 00:49:10.1775695750
On
How accurately can huge factorials be calculated?
2.3k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
1
On
Specifically, for large $x$, $$\ln(x!) = (\ln(x)-1) x + \frac{1}{2} \ln(x)+\frac{1}{2} \ln(2\pi)+\frac{1}{12 x}-\frac{1}{360x^3}+\frac{1}{1260 x^5}-\frac{1}{1680 x^7} + \frac{t}{1188 x^9}$$ for some $t \in (0,1)$. For $x = 10^{20}$, the uncertainty in the number (if calculated with a few hundred digits of precision) is about $10^{-183}$. The result is that we can say $(10^{20})!$ has
$$1956570551809674817246$$
decimal digits, of which the first 100 are
$$1932849514310097712837014080536242806874079839409160617974884639778977403427259721535932189240606200...$$
Stirling's approximation is very accurate for large numbers, so the number of digits is the integer part of
$$\log \left( \sqrt{2 \pi n} \left( \frac{n}{e} \right)^n \right) = n ( \log n - \log e) + \log \sqrt{2 \pi} + \frac{1}{2} \log n$$
where $n = 10^{20}$. The leading term in the above is $n \log n = 20 \cdot 10^{20} = 2 \cdot 10^{21}$, and any reasonable computer method for high-precision arithmetic will tell you the rest of the digits fairly easily if you want.
The leading digit can be calculated by computing the leading digit of $10^f$ where $f$ is the fractional part of the above. Again, this is relatively easy to do with any reasonable computer method for high-precision arithmetic (which I don't have access to at the moment, unfortunately, and I can't figure out how to get WolframAlpha to do this computation). By computing more digits of $f$ you can compute more leading digits (up to the accuracy of Stirling's formula).
If you really need to do this, it's worth noting that there are additional terms you can tack onto Stirling's formula for more accuracy.