Skip to content

Commit a91f0e7

Browse files
SandersLintapaswenipathak
authored andcommitted
Updated Euler problem 21 sol1.py
1 parent a170997 commit a91f0e7

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

project_euler/problem_21/sol1.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,7 @@ def sum_of_divisors(n):
2424
total += i + n//i
2525
elif i == sqrt(n):
2626
total += i
27-
2827
return total-n
2928

30-
sums = []
31-
total = 0
32-
33-
for i in xrange(1, 10000):
34-
n = sum_of_divisors(i)
35-
36-
if n < len(sums):
37-
if sums[n-1] == i:
38-
total += n + i
39-
40-
sums.append(n)
41-
42-
print(total)
29+
total = [i for i in range(1,10000) if sum_of_divisors(sum_of_divisors(i)) == i and sum_of_divisors(i) != i]
30+
print(sum(total))

0 commit comments

Comments
 (0)