#K65877. Palindromic Primes in a Range
Palindromic Primes in a Range
Palindromic Primes in a Range
You are given two integers a and b with a ≤ b. Your task is to find all the palindromic prime numbers in the inclusive range [a, b]. A palindromic number is one that remains the same when its digits are reversed. In mathematical notation, a number \( n \) is palindromic if
\[
n = \text{reverse}(n),
\]
where reverse(n)
denotes the number obtained by reversing the digits of n
.
A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. Your solution should first find all prime numbers in the range [a, b] and then filter those that are palindromic.
If there are no palindromic primes in the specified range, output None
.
inputFormat
The input consists of two space-separated integers a and b read from stdin. You may assume that 1 ≤ a ≤ b and b is not excessively large.
outputFormat
Output the palindromic prime numbers in the range [a, b] in ascending order separated by a space on a single line to stdout. If there is no such number, output None
.
1 100
2 3 5 7 11