mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
Solves problem 16
Prepares problem 20
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
# jlengrand
|
# jlengrand
|
||||||
#Created on : Fri Jan 13 15:24:59 CET 2012
|
#Created on : Fri Jan 13 15:24:59 CET 2012
|
||||||
#
|
#
|
||||||
# DESCRIPTION : Solves problem 11 of Project Euler
|
# DESCRIPTION : Solves problem 16 of Project Euler
|
||||||
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
|
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?
|
What is the sum of the digits of the number 2^1000?
|
||||||
##---
|
##---
|
||||||
@@ -13,8 +13,7 @@ def sum_power_2(value):
|
|||||||
"""
|
"""
|
||||||
Returns the sum of the digits of 2^value
|
Returns the sum of the digits of 2^value
|
||||||
"""
|
"""
|
||||||
|
return sum([int(el) for el in list(str(pow(2, value)))])
|
||||||
return 1
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print "Answer : %d" % (sum_power_2(1000))
|
print "Answer : %d" % (sum_power_2(1000))
|
||||||
22
e_20.py
Executable file
22
e_20.py
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
##---
|
||||||
|
# jlengrand
|
||||||
|
#Created on : Fri Jan 13 15:41:12 CET 2012
|
||||||
|
#
|
||||||
|
# DESCRIPTION : Solves problem 20 of Project Euler
|
||||||
|
n! means n (n 1) ... 3 2 1
|
||||||
|
For example, 10! = 10 9 ... 3 2 1 = 3628800,
|
||||||
|
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
||||||
|
Find the sum of the digits in the number 100!
|
||||||
|
##---
|
||||||
|
"""
|
||||||
|
def sum_fact(value):
|
||||||
|
"""
|
||||||
|
Returns the sum of digits in value!
|
||||||
|
"""
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print "Answer : %d" % (sum_fact)
|
||||||
Reference in New Issue
Block a user