#K67907. Palindromic Prime Digit Numbers

    ID: 32746 Type: Default 1000ms 256MiB

Palindromic Prime Digit Numbers

Palindromic Prime Digit Numbers

Given an integer \( n \), your task is to find all numbers in the range \( [1, n] \) (inclusive) that satisfy the following properties:

  • The number is palindromic, i.e. it reads the same forward and backward.
  • Each digit of the number is a prime digit. The prime digits are \( \{2, 3, 5, 7\} \).

For example, if \( n = 50 \), the valid numbers are: 2, 3, 5, 7, 22, and 33.

Your solution should read an integer from standard input and print all valid numbers in increasing order to standard output, separated by a single space. If no valid numbers exist, output an empty line.

inputFormat

The input consists of a single integer \( n \) (\( n \ge 0 \)) provided via standard input.

outputFormat

Output all numbers from 1 to \( n \) that are palindromic and contain only the prime digits \( \{2, 3, 5, 7\} \). The numbers should be printed in increasing order, separated by a single space. If there are no such numbers, output an empty line.

## sample
0