Files
project_euler/e_16.py
Julien Lengrand-Lambert 03a95ce587 Solves problem 16
Prepares problem 20
2012-01-13 15:42:45 +01:00

20 lines
497 B
Python
Executable File

#!/usr/bin/env python
"""
##---
# jlengrand
#Created on : Fri Jan 13 15:24:59 CET 2012
#
# DESCRIPTION : Solves problem 16 of Project Euler
2^15 = 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?
##---
"""
def sum_power_2(value):
"""
Returns the sum of the digits of 2^value
"""
return sum([int(el) for el in list(str(pow(2, value)))])
if __name__ == '__main__':
print "Answer : %d" % (sum_power_2(1000))