#C10115. Find Palindromic Primes
Find Palindromic Primes
Find Palindromic Primes
You are given an integer n. Your task is to generate a list of all palindromic prime numbers that are less than or equal to n.
A number is said to be palindromic if it remains the same when its digits are reversed. A number is prime if it is greater than 1 and has no positive divisors other than 1 and itself.
More formally, for a given integer \( n \), find all numbers \( p \) that satisfy:
\[ \begin{aligned} &p \leq n,\\ &p \text{ is prime},\\ &p = \text{reverse}(p). \end{aligned} \]The output should be printed as a list in the following format:
[element1, element2, ...]
If there are no such numbers, output an empty list []
. Note that the input can be zero or negative, in which case you should output an empty list.
inputFormat
The input consists of a single integer n
from standard input.
outputFormat
Output the list of palindromic primes (formatted as a Python-style list) to the standard output.
## sample100
[2, 3, 5, 7, 11]