-3

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.

fabul
  • 79

2 Answers2

1

If I understand you correctly, then you can do the following:

  1. Take the $\log$ of $2^M$ and $n!$ to compare the values.

  2. Using Stirling approximation, you'd obtain something like: $$ M \approx n \log n - n + \log \sqrt{2\pi n} $$

  3. 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 $$

openspace
  • 6,766
  • 3
  • 19
  • 38
  • There are some factors of $\log 2$ missing. – Pranay Jan 24 '25 at 08:59
  • "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
  • 3
    This 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
-1

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

Henry
  • 169,616
  • 3
    This 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