-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem 23G.py
30 lines (26 loc) · 965 Bytes
/
Problem 23G.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
# Runtime - 3 seconds 75 milliseconds (3.075 seconds)
from math import sqrt, floor
from myFunctionsG import prime_checker as isprime, execute_this
@execute_this
def Problem_23():
def abundant(num):
if isprime(num):
return False
factor, SumOfFactors, endPoint = 2, 1, floor(sqrt(num))+1
while factor < endPoint:
if not (num % factor):
SumOfFactors += factor + num // factor
factor += 1
temp = sqrt(num)
if temp.is_integer():
SumOfFactors -= temp
if SumOfFactors > num:
return True
return False
all_nums = [x for x in range(28123)]
abundant_numbers = tuple(filter(abundant, all_nums[12:]))
for i in range(len(abundant_numbers)):
for j in range(i, len(abundant_numbers)):
if (temp := abundant_numbers[i] + abundant_numbers[j]) < 28123:
all_nums[temp] = 0
print(sum(all_nums))