mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08: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
|
total += i + n//i
|
||||||
elif i == sqrt(n):
|
elif i == sqrt(n):
|
||||||
total += i
|
total += i
|
||||||
|
|
||||||
return total-n
|
return total-n
|
||||||
|
|
||||||
sums = []
|
total = [i for i in range(1,10000) if sum_of_divisors(sum_of_divisors(i)) == i and sum_of_divisors(i) != i]
|
||||||
total = 0
|
print(sum(total))
|
||||||
|
|
||||||
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)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user