#K52807. Smallest Palindromic Prime
Smallest Palindromic Prime
Smallest Palindromic Prime
Given an integer N
, find and output the smallest palindromic prime number that is greater than or equal to N
.
A number is palindromic if it reads the same backward as forward, e.g., 121 or 131. A number is prime if it is greater than 1 and has no positive divisors other than 1 and itself. The answer must satisfy both properties.
Your task is to implement a program that reads an integer from standard input and prints the result on standard output.
The solution involves checking for palindromicity and primality for numbers starting from N
until a valid number is found.
inputFormat
The input consists of a single integer N
which represents the starting number.
Input Format: A single line containing the integer N
.
outputFormat
Output the smallest palindromic prime number that is greater than or equal to N
.
Output Format: A single integer printed on a single line.
## sample150
151