-
Notifications
You must be signed in to change notification settings - Fork 0
/
23.py
43 lines (37 loc) · 843 Bytes
/
23.py
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
38
39
40
41
42
import math
def getDivisorsSum (num):
n = math.floor(math.sqrt(num))
total = 1
divisor = 2
while (divisor <= n):
if (num%divisor == 0):
total += divisor
total += num//divisor
divisor+=1
if (n**2 == num):
total -= n
return total
def isAbundant(num):
if (getDivisorsSum (num) > num):
return True
else:
return False
abundentNums = []
for x in range (0,28124):
if (isAbundant(x)):
abundentNums.append(x)
del abundentNums[0]
sums = [0]*28124
for x in range (0, len(abundentNums)):
for y in range (x, len(abundentNums)):
sumOf2AbundantNums = abundentNums[x]+abundentNums[y]
if (sumOf2AbundantNums> 28123):
break
else:
if (sums[sumOf2AbundantNums] == 0):
sums[sumOf2AbundantNums] = sumOf2AbundantNums
total = 0
for x in range (1,len(sums)):
if (sums[x] == 0):
total +=x
print('\n', total)