mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-18 16:27:02 +00:00
Updated Euler problem 21 sol1.py
This commit is contained in:
parent
a170997eaf
commit
a91f0e7ca0
|
@ -24,19 +24,7 @@ def sum_of_divisors(n):
|
|||
total += i + n//i
|
||||
elif i == sqrt(n):
|
||||
total += i
|
||||
|
||||
return total-n
|
||||
|
||||
sums = []
|
||||
total = 0
|
||||
|
||||
for i in xrange(1, 10000):
|
||||
n = sum_of_divisors(i)
|
||||
|
||||
if n < len(sums):
|
||||
if sums[n-1] == i:
|
||||
total += n + i
|
||||
|
||||
sums.append(n)
|
||||
|
||||
print(total)
|
||||
total = [i for i in range(1,10000) if sum_of_divisors(sum_of_divisors(i)) == i and sum_of_divisors(i) != i]
|
||||
print(sum(total))
|
||||
|
|
Loading…
Reference in New Issue
Block a user