1

I'm wondering if there is a formula for the number of digits in $2^x$.

For example if $x = 3$ then the number of digits is equal to $1$ because $2^3 = 8$ or for example if $x = 4$ then the number of digits is equal to $2$ because $2^4 = 16$.

In an attempt to solve this problem on my own I made the following table:

2^1 = 1
2^2 = 1
2^3 = 1
2^4 = 2
2^5 = 2
2^6 = 2
2^7 = 3
2^8 = 3
2^9 = 3
2^10 = 4
2^11 = 4
2^12 = 4
2^13 = 4
2^14 = 5

At first it looks like there is a pattern of threes but then $10$-$13$ ruins it. It's late and I can't think of any other way to approach this problem, any help would be awesome.

The question is $2^x \ge 100\,000\,000$ digits.

Start wearing purple
  • 53,234
  • 13
  • 164
  • 223
java
  • 311
  • Use the fact that $\log_{10}2\approx 0.3$ – Artem Oct 07 '13 at 01:54
  • 2
    Actually, $\log_{10}2\approx 0.3$ (which comes from $2^{10}=1024\approx 1000$) does get you quite far because $\log_{10}2\approx 0.30103$. – lhf Oct 07 '13 at 02:01

1 Answers1

7

Number of digits in $n$ is given by $1+\lfloor\log_{10}(n) \rfloor$. Hence, in your case, the number of digits in $2^x$ is given by $$1+\lfloor x \log_{10}2 \rfloor$$ where $\lfloor y \rfloor$ is the greatest integer $\leq y$. For instance, $\lfloor 3.4 \rfloor =3$; $\lfloor 4.1244 \rfloor =4$; $\lfloor -6.0926 \rfloor =-7$;

  • sorry if this is a stupid question... I'm just taking precalc now but are those bracket things an int function? – java Oct 07 '13 at 01:58
  • 1
    @java Have edited the answer to clarify your question. –  Oct 07 '13 at 02:00
  • http://www.wolframalpha.com/input/?i=1%2B%E2%8C%8Axlog2%E2%8C%8B%3D+100000000 – java Oct 07 '13 at 02:01
  • @java those "bracketed things" is a floor function. It returns integral part of its input. For example ⌊2.45⌋=2, ⌊-1.23⌋=-2 here's link to wikipedia http://goo.gl/nnYzx – kalimba Oct 07 '13 at 04:37