-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path021.py
48 lines (40 loc) · 1 KB
/
021.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
import math
def euler(n):
res_final = []
f_res_final = []
res_sum = 0
for t in range(1, n+1):
preo = divarr(t)
pret = divarr(preo)
if t == pret and preo != pret:
res_final.append(t)
res_final.append(preo)
# for each in res_final:
# if each not in f_res_final:
# f_res_final.append(each)
f_res_final = list(set(res_final))
f_res_final.sort()
# print(f_res_final)
for each in f_res_final:
res_sum += each
print(res_sum)
def divarr(k):
arr_divisors = []
res_arr = []
res = 0
for p in range(1,math.ceil(k//2)+1):
if k % p == 0:
arr_divisors.append(p)
arr_divisors.append(k//p)
# for each in arr_divisors:
# if each not in res_arr:
# res_arr.append(each)
res_arr = list(set(arr_divisors))
res_arr.sort()
if res_arr:
res_arr.remove(k)
for each in res_arr:
res += each
return res
euler(10000)
# 31626