-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem_027.py
More file actions
38 lines (33 loc) · 835 Bytes
/
Copy pathproblem_027.py
File metadata and controls
38 lines (33 loc) · 835 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
# Date: 2025.07..20
# Answer: -59231
import math
def is_prime(value):
if value < 0:
return False
for i in range(2,math.ceil(value/2+1)):
if value % i == 0:
return False
return True
def consecutive_primes(a,b):
count = 0
n=0
while True:
value = n*n+a*n+b
if(is_prime(value)):
count+=1
n+=1
else:
return count
largest = 0
best_a = 0
best_b = 0
for a in range(-999,1000):
for b in range (-1000,1001):
print(f"currently processing {a} {b} ",end="\r")
count = consecutive_primes(a,b)
if count>largest:
largest = count
best_a = a
best_b = b
print(f"a: {a} b: {b} longest sequence: {largest}")
# print(consecutive_primes(-9999,-1000))