We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a170997 commit a91f0e7Copy full SHA for a91f0e7
project_euler/problem_21/sol1.py
@@ -24,19 +24,7 @@ def sum_of_divisors(n):
24
total += i + n//i
25
elif i == sqrt(n):
26
total += i
27
-
28
return total-n
29
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)
+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))
0 commit comments