Find the prime number closest to the given integer .
[THOUGHT]
I will search for the nearest prime to N = 12269117 by checking N itself for primality, then expanding outward to N-1, N+1, N-2, N+2, etc., until a prime is found. I will use sympy's isprime for reliability and speed, then determine the closest prime (and if needed, handle a tie by checking both sides' distances).
[/THOUGHT]
[PYTHON]
from sympy import isprime
N = 12269117
if isprime(N): print("Nearest prime:", N) else: d = 1 lower_prime = None upper_prime = None while True: if N - d > 1 and isprime(N - d): lower_prime = N - d break if isprime(N + d): upper_prime = N + d break d += 1
# If we found one side first in the loop, it's automatically the nearest,
# because we expanded symmetrically.
print("Nearest prime:", lower_prime if lower_prime is not None else upper_prime)
print("Distance:", d)
print("Lower candidate:", lower_prime, "Upper candidate:", upper_prime)
[/PYTHON]
[THOUGHT] The Python result shows the nearest prime to 12269117 is 12269137 at distance 20, with no closer lower prime found. This is the required closest prime. [/THOUGHT] \boxed{12269137}