-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerfect_Nunbers.py
51 lines (48 loc) · 968 Bytes
/
Perfect_Nunbers.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
import time
start = time.time()
k = 3
def factors(num):
L = list()
factors = list()
i = 2
while i < num:
if num%i == 0:
L.append(i)
num /= i
i = 2
continue
if i == num-1:
L.append(num)
i += 1
i = 0
_len = len(L)
while i < _len-1:
j = i+1
p = L[i]
while j < _len and _len > 2:
y = L[i]*L[j]
if y not in L:
L.append(y)
if not (i == 0 and j==_len-1):
p*=L[j]
if p not in L:
L.append(p)
j+=1
i+=1
for x in L:
if x not in factors:
factors.append(x)
return [1]+factors
i = 3
print(6)
while True:
if not i%9 == 1:
i += k
k += 1
continue
L = factors(i)
if sum(L) == i:
print(time.time() - start)
print(i)
i += k
k += 1