euler/python/e046.py

23 lines
526 B
Python
Raw Normal View History

2019-07-18 03:29:59 +02:00
from lib_prime import is_prime
def euler_046():
2019-07-18 03:29:59 +02:00
n_max = 10000
twice_squares = [2 * n * n for n in range(1, n_max + 1)]
def test_conjecture(n):
for ts in twice_squares:
if ts > n:
return False
if is_prime(n - ts):
return True
for n in range(3, n_max + 1, 2):
if not is_prime(n) and test_conjecture(n) is False:
return n
if __name__ == "__main__":
print("e046.py: " + str(euler_046()))
2019-07-18 03:29:59 +02:00
assert(euler_046() == 5777)