euler/e016.py
Correl Roush 12c5dd7875 Documented each exercise, and placed executable code in a main() function.
git-svn-id: file:///srv/svn/euler@63 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
2010-05-04 18:21:07 +00:00

17 lines
372 B
Python

"""What is the sum of the digits of the number 21000?
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 21000?
"""
n = 2**1000
def main():
s = str(n)
total = 0
for c in s:
total = total + int(c)
print 'Sum of digits for {0}: {1}'.format(n, total)
if __name__ == '__main__':
main()