princeofsudan

ProjectEuler#16 Power digit sum

Mar 3rd, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. #2**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
  2.  
  3. #What is the sum of the digits of the number 2**1000?
  4.  
  5. #Analysis
  6. #Calculate 21000, split the digits and add them together.
  7.  
  8. digits = str(2**1000)
  9. acc = 0
  10. for i in range(len(digits)):
  11.     acc += int(digits[i])
  12.  
  13. print acc
Advertisement
Add Comment
Please, Sign In to add comment