2
$\begingroup$

Is there an algorithm to find the number of digits in 2^2030 ?

$2^1=2$

$2^2=4$

$2^3=8$

$2^4=16$

$2^5=32$

$2^6=64$

$2^7=128$

...

$2^{10}=1024$

$\endgroup$
5
$\begingroup$

The number of digits in $2^n$ is $1+floor(n \log_{10} 2)$.

Using $\log_{10} 2 \approx 0.30103$ gives you 612 digits.

Here is an explanation:

A number $x$ has $k$ digits in base 10 iff $10^{k-1} \le x < 10^k$. Taking logs, we get $k-1 \le \log_{10} x < k$, which means that $floor(\log_{10} x)=k-1$. So, $k=1+floor(\log_{10} x)$.

An answer to the question in the title needs high-precision approximations of $\log_{10} 2$.

$\endgroup$
  • $\begingroup$ Care to explain why is this the case? $\endgroup$ – JohnWO Jun 21 '13 at 12:52
  • $\begingroup$ @JohnWO, see my edited answer. $\endgroup$ – lhf Jun 21 '13 at 13:00
  • 1
    $\begingroup$ See also oeis.org/A129344 and try to find a pattern. $\endgroup$ – lhf Jun 21 '13 at 13:08
  • $\begingroup$ You can use \lfloor and \rfloor to get the $\lfloor$ and $\rfloor$ symbols. $\endgroup$ – Peter Phipps Jun 21 '13 at 13:09
  • $\begingroup$ @PeterPhipps, I know. I was lazy and also not sure the OP would understand the notation. $\endgroup$ – lhf Jun 21 '13 at 13:10
3
$\begingroup$

Just for fun, let's suppose you don't have access to floating-point computations, but you can compute with rational numbers. We have the series (for $|x|<1$) $$ \ln \left( \frac{1+x}{1-x}\right) = 2 x + \frac{2}{3} x^3 + \frac{2}{5} x^5 + \frac{2}{7} x^7 + \ldots$$ and in particular, if $0 < x < 1$, $$ 2 x + \frac{2}{3} x^3 + \frac{2}{5} x^5 + \frac{2}{7} x^7 < \ln\left( \frac{1+x}{1-x}\right) < 2 x + \frac{2}{3} x^3 + \frac{2}{5} x^5 + \frac{2 x^7}{7(1 - x^2)}$$ For $x = 1/3$ this gives us $$ \dfrac{53056}{76545} < \ln(2) < \dfrac{23581}{34020}$$ while for $x = 1/9$ we have $$ {\frac {37355104}{167403915}} < \ln \left( 5/4 \right) < {\frac { 3689393}{16533720}} $$ Then $2030 \log_{10}(2) = \dfrac{2030 \ln 2}{\ln(5/4) + 3 \ln(2)}$ is between $\dfrac{23263994880}{38070491}$ and $\dfrac{94221399069}{154182208}$, both of which are between $611$ and $612$. So, $612$ digits.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.