I've been pondering this quirky fact about powers of 2 for a while now, and I can't seem to formulate it properly in my head to find a proper answer without just using a calculator and trying out numbers till I find the answer.
When talking about memory we usually use Megs, Gigs, etc. And usually these are technically powers of 2.
Kilo = pow(2,10)
Meg = pow(2,20)
Gig = pow(2,30)
Ok so it seems that 2 to the power of something divisible by 10 is going to be the approximation of 10 to the power of something divisible by 3 (which seems coincidental even strange to me), and by approximation I mean the first digit is a 1 and it has the correct number of digits.
Using experimentation it appears pow(2,299) is the first time this doesn't hold true, but I can't help but think there must be a way to make a formula that gives me the value without experimentation.
I know for example that log 2 is .30102… which is the reason it works for sufficiently small exponents since we want 3 extra digits each time. But what's next?
Best Answer
It sounds like you're asking the first value of $n$ such that
$$ 10^{3n} < 2^{10n} < 2 \cdot 10^{3n}$$
is false. It will be false because the second inequality is violated, so you seek
$$ 2^{10n} > 2 \cdot 10^{3n} $$ $$ 2^{10n-1} > 10^{3n} $$ $$ (10n-1) \log 2 > 3n \log 10 $$ $$ n(10 \log 2 - 3 \log 10) > \log 2 $$ $$ n > \frac{\log 2}{10 \log 2 - 3 \log 10} $$ $$ n > 29.226\ldots$$
(The inequality doesn't reverse when I divide, because I divide by a positive number).