#C14222. Prime and Palindrome Numbers Challenge
Prime and Palindrome Numbers Challenge
Prime and Palindrome Numbers Challenge
In this problem, you are required to work with prime numbers and their palindromic properties. A prime number (p) is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. A number is said to be a palindrome if it reads the same forwards and backwards (e.g. (121)).
You need to complete two tasks:
- Generate the first (n) prime numbers.
- List all prime numbers less than a given limit (L) that are also palindromic.
Your program will receive two integers as input: (n) and (L). The first line of the output should display the first (n) prime numbers separated by spaces. The second line should display all prime palindromic numbers less than (L), also separated by spaces.
Make sure your solutions read from standard input and write to standard output.
inputFormat
The input consists of a single line containing two integers (n) and (L), where (n) represents the number of prime numbers to generate, and (L) is the exclusive upper bound for searching prime palindromic numbers.
outputFormat
Output two lines:
- The first line contains the first (n) primes separated by a single space. If (n = 0), output an empty line.
- The second line contains all prime palindromic numbers less than (L) separated by a single space.## sample
5 50
2 3 5 7 11
2 3 5 7 11
</p>