#C13097. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
You are given a list of integers. Your task is to write a program that reads the list from standard input (stdin) and outputs all the prime numbers found in the list to standard output (stdout) in the same order as they appear.
A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. Use an efficient method to check whether a number is prime.
If no prime numbers exist in the input list, your program should output nothing.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains a single integer n, which represents the number of integers.
- The second line contains n space-separated integers.
outputFormat
Output the prime numbers from the list in the order they appear in the input. The numbers should be printed on a single line separated by a single space. If there are no prime numbers, output nothing.
## sample9
2 3 4 5 6 7 8 9 10
2 3 5 7