-
Notifications
You must be signed in to change notification settings - Fork 10
/
pe027.py
54 lines (43 loc) · 1.21 KB
/
pe027.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
52
53
54
def prime_check(n):
prime = False
if n > 1:
if n == 2:
return True
for i in range(2, n):
if n % i == 0:
prime = False
break
else:
prime = True
return prime
prime_sieve_1k = [i for i in range(1000) if prime_check(i)]
prime_sieve_1k_copy = prime_sieve_1k[:]
_max = 0
jmi = 0
for i in prime_sieve_1k:
for j in prime_sieve_1k:
k = 0
while True:
res = k**2 + j * k + i
if res not in prime_sieve_1k_copy:
if prime_check(res):
prime_sieve_1k_copy.append(res)
else:
if k - 1 > _max:
_max = k - 1
jmi = j * i
break
k += 1
k = 0
while True:
res = k**2 - j * k + i
if res not in prime_sieve_1k_copy:
if prime_check(res) and res > 0:
prime_sieve_1k_copy.append(res)
else:
if k - 1 > _max:
_max = k - 1
jmi = -1 * j * i
break
k += 1
print(jmi)