Adopted new convention from template
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 15 Sep 2018
|
Created on 15 Sep 2018
|
||||||
|
|
||||||
@@ -11,9 +11,11 @@ https://projecteuler.net/problem=21
|
|||||||
|
|
||||||
from utils import timeit
|
from utils import timeit
|
||||||
|
|
||||||
|
|
||||||
def sum_divisors(n):
|
def sum_divisors(n):
|
||||||
return sum(i for i in range(1, n // 2 + 1) if n % i == 0)
|
return sum(i for i in range(1, n // 2 + 1) if n % i == 0)
|
||||||
|
|
||||||
|
|
||||||
@timeit("Problem 21")
|
@timeit("Problem 21")
|
||||||
def compute():
|
def compute():
|
||||||
"""
|
"""
|
||||||
@@ -28,7 +30,8 @@ def compute():
|
|||||||
|
|
||||||
Evaluate the sum of all the amicable numbers under 10000.
|
Evaluate the sum of all the amicable numbers under 10000.
|
||||||
"""
|
"""
|
||||||
n = 10000
|
|
||||||
|
n = 10_000
|
||||||
sum_amicable = 0
|
sum_amicable = 0
|
||||||
for i in range(1, n):
|
for i in range(1, n):
|
||||||
value = sum_divisors(i)
|
value = sum_divisors(i)
|
||||||
@@ -38,5 +41,4 @@ def compute():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 21 is {compute()}")
|
||||||
print(f"Result for Problem 21: {compute()}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user