#C516. Closest Primes
Closest Primes
Closest Primes
You are given an integer ( x ). Your task is to find the closest prime numbers around ( x ). If ( x ) itself is a prime number, output it twice. Otherwise, find the largest prime number smaller than ( x ) and the smallest prime number greater than ( x ). For example, for ( x = 10 ), the closest primes are 7 and 11, and for ( x = 17 ), since 17 is prime, the answer is 17 and 17.
The algorithm involves checking for primality and then iterating downward and upward from ( x ) to locate the nearest primes. Remember that a prime is a number greater than 1 that has no divisors other than 1 and itself.
inputFormat
The input consists of a single integer ( x ) provided through standard input.
outputFormat
Output two integers separated by a space representing the closest prime less than or equal to ( x ) and the closest prime greater than or equal to ( x ).## sample
10
7 11
</p>