Find the prime number closest to the given integer .
[THOUGHT] I need to find the prime number closest to N = 12269117. I'll write a function to check primality and then search upward and downward from N until I find the nearest prime. Since N is large, I'll use an efficient primality test (e.g., Miller-Rabin deterministic for 64-bit integers). I'll also handle the case where N itself is prime. I'll search in both directions and stop when I find the first prime in either direction. I'll then compare the distances to determine which is closer. If both are equally distant (rare), I need to choose the smaller prime? The problem says "closest" – if tie, choose smaller? Usually choose smaller. I'll implement accordingly.
I'll use sympy's isprime function for reliability.
Plan:
- Define N = 12269117.
- Check if N is prime.
- If yes, answer is N.
- Else, search upward: n+1, n+2, ... until prime.
- Search downward: n-1, n-2, ... until prime.
- Compute distances and compare.
Let's code. [/THOUGHT] [PYTHON] import sympy
N = 12269117
def is_prime(n): return sympy.isprime(n)
Check N
if is_prime(N): print("N is prime") print(N) else: # search upward up = N + 1 while not is_prime(up): up += 1 # search downward down = N - 1 while not is_prime(down): down -= 1 # compare distances dist_up = up - N dist_down = N - down if dist_up < dist_down: print(up) elif dist_down < dist_up: print(down) else: # tie, choose smaller prime print(min(up, down)) [/PYTHON]
[THOUGHT] The Python output indicates that the closest prime to 12269117 is 12269137. Therefore, the final answer is 12269137.
\boxed{12269137}