2019-07-18 03:29:59 +02:00
|
|
|
from lib_prime import is_prime
|
|
|
|
|
2019-07-17 03:17:21 +02:00
|
|
|
|
|
|
|
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
|
2019-07-17 03:17:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print("e046.py: " + str(euler_046()))
|
2019-07-18 03:29:59 +02:00
|
|
|
assert(euler_046() == 5777)
|