-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path23.py
52 lines (39 loc) · 1.23 KB
/
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
43
44
45
46
47
48
49
50
51
52
#-*-coding:utf8;-*-
#qpy:3
#qpy:console
'''Thanks Stack Overflow!'''
def factorizer(number,limit):
factors = []
gate = isinstance(limit,int)
for x in range(1,int(number ** 0.5) + 1):
'''if x % round(number / 100) == 0:
print("Iteration: {}".format(x))'''
if number % x == 0:
factors.append(x)
if x != int(number / x):
factors.append(int(number / x))
if gate == True:
if len(factors) > limit:
break
factors.sort()
return factors
def is_abundant(number):
number_factors = factorizer(number,"")[:-1]
if sum(number_factors) > number:
return True
else:
return False
abundants = [number
for number in range(1,28123 + 1)
if is_abundant(number)]
print("Made abundants")
not_addends = {abundant + bundant
for abundant in abundants
for bundant in abundants[abundants.index(abundant):]
if abundant + bundant < 28123 + 1}
print("Made not addends")
addends = [number
for number in range(1,28123 + 1)
if number not in not_addends]
print("Made addends")
print(sum(addends))