Solution to problem 16
This commit is contained in:
parent
9c0c031509
commit
e43b2a981a
28
src/Python/Problem016.py
Normal file
28
src/Python/Problem016.py
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Created on 13 Jan 2018
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for problem 16 of Project Euler
|
||||
https://projecteuler.net/problem=16
|
||||
"""
|
||||
|
||||
from utils import timeit
|
||||
|
||||
|
||||
@timeit("Problem 16")
|
||||
def compute():
|
||||
"""
|
||||
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?
|
||||
"""
|
||||
n = 1000
|
||||
return sum(int(digit) for digit in str(2**n))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 16: {compute()}")
|
Loading…
x
Reference in New Issue
Block a user