Project Euler - Problem 16


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2.  
  3. # Project Euler - Problem 16
  4.  
  5. print "\nProject Euler - Problem 16"
  6. print " What is the sum of the digits of 2^1000?\n"
  7.  
  8. num = 2**1000
  9. sum = 0
  10. str = str(num)
  11.  
  12. for x in str:
  13. sum += int(x)
  14.  
  15. print sum

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.