Is this possible to find the distance between a big power of 2 lets say 2^77233199 and the nearest factorial before or after this power of 2 ? My guess is to estimate it with Stirling formula.
-
1If I understand you correctly, you given the $2^M$, you want to estimate $n$: $|2^M - n!|$ is minimal? – openspace Jan 24 '25 at 08:50
-
i have 2^77233199 i want to estimate where is n! o m!, n can be the factorial after 2^77233199 or m can be the factorial before 2^77233199 i don't know n or m and the distance between n or m and 2^77233199 – fabul Jan 24 '25 at 09:05
-
1if i take 2^127 : 33! < 2^127 < 34! and distance is -161457865841657345236169109314604105728 and 125091615579134909115931305927635894272 – fabul Jan 24 '25 at 09:11
-
Is this possible to estimate or calculate this factorial and estimate disance to the power of 2 ? – fabul Jan 24 '25 at 09:16
-
For some basic information about writing mathematics at this site see, e.g., basic help on mathjax notation, mathjax tutorial and quick reference, main meta site math tutorial and equation editing how-to. – Henrik supports the community Jan 24 '25 at 10:27
2 Answers
If I understand you correctly, then you can do the following:
Take the $\log$ of $2^M$ and $n!$ to compare the values.
Using Stirling approximation, you'd obtain something like: $$ M \approx n \log n - n + \log \sqrt{2\pi n} $$
I don't see the way of solving the latter equation, but it's possible to solve approximation of it using Lambert function:
$$ M = x \log x - x \iff x = W(a/e) + 1 $$
- 6,766
- 3
- 19
- 38
-
-
"closest in logarithms" is not the same as "closest". For instance, $\log 4-\log 2>\log 7-\log 4$. – Chris Lewis Jan 24 '25 at 09:33
-
@ChrisLewis No, but logarithms could narrow it down to the next-largest and next-smallest, and then the closest one must be one of those two. – Toph Jan 24 '25 at 09:45
-
3This question seems not to meet the standards for the site (no context given and almost no effort). Instead of answering it, it would be better to look for a good duplicate target, or help the user by posting comments suggesting improvements. Please also read the meta announcement regarding quality standards. – Martin Brandenburg Jan 24 '25 at 09:46
-
@Toph yes, but that point should be made in the solution. That said, I agree with MartinBrandenburg about the quality of this question. – Chris Lewis Jan 24 '25 at 09:51
An answer in Is there an inverse to Stirling's approximation? suggests that
$$ x = \frac{{\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)}}{{W\!\left( {\frac{1}{\mathrm{e}}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right)}} - \frac{1}{2} $$
is a good approximation to the solution of $y=x!$.
Using R to apply that here
library(pracma)
logy <- 77233199*log(2)
(logy-log(sqrt(2*pi))) / lambertW(exp(-1)*(logy-log(sqrt(2*pi)))) - 1/2
# 3784290.23
and testing either side of this gives
$2^{77233199} \approx 3.6\times 10^{23249509}$
$3784290! \approx 1.1\times 10^{23249508}$
$3784291! \approx 4.2\times 10^{23249514}$
so $3784290!$ is the closest factorial to $2^{77233199}$
How to solve factorial equations with very big numbers is a related question
- 169,616
-
3This question seems not to meet the standards for the site (no context given and almost no effort). Instead of answering it, it would be better to look for a good duplicate target, or help the user by posting comments suggesting improvements. Please also read the meta announcement regarding quality standards. – Martin Brandenburg Jan 24 '25 at 09:58