-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem 46.py
More file actions
56 lines (47 loc) · 1.14 KB
/
Copy pathProblem 46.py
File metadata and controls
56 lines (47 loc) · 1.14 KB
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
53
54
55
56
import math as mt
MAXN = 1000001
spf = [0 for i in range(MAXN)]
def sieve():
spf[1] = 1
for i in range(2, MAXN):
spf[i] = i
for i in range(4, MAXN, 2):
spf[i] = 2
for i in range(3, mt.ceil(mt.sqrt(MAXN))):
if (spf[i] == i):
for j in range(i * i, MAXN, i):
if (spf[j] == j):
spf[j] = i
def krdo(x):
ret = list()
while (x != 1):
ret.append(spf[x])
x = x // spf[x]
return ret
sieve()
# calling getFactorization function
A = []
XX = {}
for i in range(3, 100000):
if len(krdo(i)) == 1:
A.append(i)
XX[i] = True
for i in range(1, 100000, 2):
Done = True
try:
if XX[i]:
continue
except Exception:
for j in A:
if j >= i:
break
else:
X = ((i - j)//2)**0.5
if int(X) == X:
Done = True
break
else:
Done = False
if not Done:
print(i)
break