PDA

View Full Version : Find the Sum of the Digits of 2^1000


ring_wraith
30-07-2008, 07:42 PM
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.

What is the sum of the digits of the number 2^1000?

Ripped off from Project Euler. Any solutions anyone?

QwertyManiac
30-07-2008, 08:05 PM
Isn't it straightforward? Or are you looking for non-bruteforce methods. I don't know of a way if so.

Is a nice one-liner in most languages otherwise.

Edit: Guess you are wondering how to store such a large number? Using modulo (10) can help in that case. You need to understand a bit more of multiplication. Else just use BigNum/Etc :)

ring_wraith
30-07-2008, 08:33 PM
Modulo ? Can you elaborate on that?