Practice
Junior Example Problem 2: Palindromic Primes
What are Palindromic Primes?
- A Palindromic Primes is a prime number and it is also a palindrome (it reads the same forwards as backwards).
- For example, 151 is prime and palindrome it reads the same forwards as backwards.
Example
-
The palindromic primes between 1 and 150 are
2
3
5
7
11
101
131
- Note: 1 is not prime.
Instructions
- Write a program that will read in a pair of numbers, then output all palindromatic primes between those two numbers (inclusive).
- This should continue until a pair of zeros is read in.
- Your output should contain each palindromatic prime on a singel line.
- Output sould be in ascending order.
- No other output should be produced by your program other than the numbers.
- Your output should be based in the following input.
Data
1 1000
10000 32000
152 768
0 0