-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23.py
More file actions
38 lines (25 loc) · 761 Bytes
/
23.py
File metadata and controls
38 lines (25 loc) · 761 Bytes
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
#!/usr/bin/env python
# Marks abundant numbers and sums integers that cannot be written as two abundant numbers.
"""Project Euler Problem 23: https://projecteuler.net/problem=23"""
from datetime import date, timedelta
from collections import defaultdict
sz = 28123
num = []
import math
for i in range(12, sz + 1):
temp_sum = 1
for j in range(2, int(math.sqrt(i)) + 1):
if i % j == 0:
temp_sum += j
x = i // j
if x != j:
temp_sum += x
if temp_sum > i:
num.append(i)
ans = set()
for idx, i in enumerate(num):
# print(i)
for j in range(idx, len(num)):
if num[idx] + num[j] <= sz:
ans.add(num[idx] + num[j])
print(28123 * 28124 / 2 - sum(ans))