mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-24 09:21:24 -04:00
reorganize dir
Signed-off-by: Mia Steinkirch <mia.steinkirch@gmail.com>
This commit is contained in:
parent
1b6f705e7c
commit
a8e71c50db
276 changed files with 23954 additions and 0 deletions
22
other_resources/Project-Euler/016-power_digit_sum.py
Normal file
22
other_resources/Project-Euler/016-power_digit_sum.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/python3
|
||||
# mari von steinkirch @2013
|
||||
# steinkirch at gmail
|
||||
|
||||
|
||||
def power_digit_sum(n):
|
||||
number = str(2**n)
|
||||
sum_res = 0
|
||||
for i in number:
|
||||
sum_res += int(i)
|
||||
return sum_res
|
||||
|
||||
|
||||
|
||||
def test_():
|
||||
assert(power_digit_sum(15) == 26)
|
||||
print(power_digit_sum(1000))
|
||||
print('Tests Passed!')
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue