-
Notifications
You must be signed in to change notification settings - Fork 0
/
pro23.py
47 lines (41 loc) · 940 Bytes
/
pro23.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
43
44
45
46
47
from __future__ import print_function
def divsum(n):
s = 0
t = n**0.5
for i in range(1, int(t)+1):
if n % i == 0: s += i + n/i
if t == int(t): s -= t #correct s if t is a perfect square
s -= n
return s
def abundant(n):
abun = []
for i in range(1,n):
if divsum(i) > i:
abun.append(i)
return abun
def multwo(l):
multwo = []
for i in l:
multwo.append(2*i)
return multwo
lists = abundant(28124)
liststwo = multwo(lists)
s = 0
for i in range(1,28124):
if i in liststwo:
continue
elif i < 945 and i%2 != 0:
s += i
# print(i)
else:
isSumofAbun = False
for j in [m for m in lists if m < i]:
if j == 0:
continue
if i-j in lists:
isSumofAbun = True
break
if not isSumofAbun:
# print(i)
s += i
print (s)