#C13351. Prime Filter
Prime Filter
Prime Filter
This problem requires you to filter out prime numbers from a given list of integers.
A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. You need to implement the functionality to check if a number is prime and then use it to extract all prime numbers from the input list in the order they appear.
Your solution should read from stdin
and print the result to stdout
. The output should contain the prime numbers separated by a single space. If there are no prime numbers in the input, output an empty line.
inputFormat
The first line contains an integer n which represents the number of elements in the list.
The second line contains n space-separated integers representing the elements of the list.
outputFormat
Output a single line containing all the prime numbers from the input list separated by a space. If no prime numbers exist, output an empty line.
## sample10
1 2 3 4 5 6 7 8 9 10
2 3 5 7