# Find the number of digits of N and their sum (Power of two)

I'm looking for an algorithm to determine how many numbers the 2013th power of two have and other for the sum of their digits. $$2^{2013}$$

So far the only thing I have noted is that:

For powers that are greater than 10

The sum of the digits of the n´th power of two is equal to the sum of (n-10 + n-9 + n -8)

$$2^n = (2^{n-10}+2^{n-9} + 2^{n-8})$$

Apparently there is no pattern for $$2^{2013}$$ What about for finding the sum of the numbers of $$2^{2010}\cdot 125^{671}$$

• I don't think there is a way to do it by hand. – MonkeyKing Apr 29 '15 at 22:09
• There must be a way – Juanvulcano Apr 29 '15 at 22:16
• I mean without brute force. – MonkeyKing Apr 29 '15 at 22:20

If you are looking for the number of digits of a number, you have to write it as a power of 10 and check the exponent:

$2^{2013} = 10^x$
$log 2^{2013} = log 10^x$
$2013 log 2 = x log 10$
$x = 2013 log 2$
$x = 605.9733812715941459652563950804$

This means we have 606 digits, not necessarily all of them equal to zero because x has digits to the right of the decimal dot. Evaluating the decimal part of x gives us a clue as to the digits that are not zero:

$10^{.9733812715941459652563950804}=9.4054866556866930625153695840476$

The sum of each digit from the right side of the equation above is the sum of the digits of $2^{2013}$. For the result to be exact, the power of 10 has to have a resolution of at least 606 digits, or else digits will be lost.

The following Matlab program computes the sum of digits using symbolic computation and variable-precision arithmetic:

N = 200; %// maximum power
y = NaN(1,N);
for n = 1:N;
x = char(vpa(2^n, N)); %// N digits is more than enough. Could be optimized
x = x(1:end-2); %// remove ending ".0"
y(n) = sum(x-'0'); %// sum digit values
end
plot(1:N, y)


See result for the first 200 values: if there's a pattern, it must be a very complicated one.