38 lines
892 B
Python
38 lines
892 B
Python
|
|
from tools import number_theory
|
|
|
|
def test_prime(x, prime):
|
|
for p in prime:
|
|
if p ** 2 > x:
|
|
return True
|
|
if not (x % p):
|
|
return False
|
|
return False
|
|
|
|
def gen_value(a, b):
|
|
n = 0
|
|
x = b
|
|
prime = list(number_theory.make_prime(10000))
|
|
while True:
|
|
if prime[-1] ** 2 < x:
|
|
prime = list(number_theory.make_prime(prime[-1] * 2 + 1))
|
|
if 0 > x:
|
|
return
|
|
if not test_prime(x, prime):
|
|
return
|
|
yield x
|
|
x += 2 * n + a + 1
|
|
n += 1
|
|
|
|
def test_polynomial(limit):
|
|
maxi = [0, (0, 0)]
|
|
for b in number_theory.make_prime(limit):
|
|
for a in range(-b, 0, 2):
|
|
l = len(list(gen_value(a, b)))
|
|
if l > maxi[0]:
|
|
maxi = [l, (a, b)]
|
|
print(maxi)
|
|
return maxi[1][0] * maxi[1][1]
|
|
|
|
print(test_polynomial(1000))
|