summaryrefslogtreecommitdiff
path: root/023.py
blob: d109302a7f66a54ad0002d49488f0fccd3d5837d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import math

limit = 28123
numbers = set()

def abundant(n):
	divisors = set()
	divisors.add(1)
	for i in xrange(2, int(math.sqrt(n))+1):
		if n % i == 0:
			divisors.add(i)
			divisors.add(n/i)

	if sum(divisors) > n:
		return True
	else:
		return False

def sum_abundant(n):
	for i in numbers:
		if n-i in numbers:
			return True
	return False


for n in xrange(2, limit+1):
	if abundant(n):
		numbers.add(n)

sum = 0

for n in xrange(limit+1):
	if not sum_abundant(n):
		sum += n

print sum