#C13734. Filter Prime Numbers from a List
Filter Prime Numbers from a List
Filter Prime Numbers from a List
You are given a list of integers. Your task is to filter out the prime numbers from the list and print them in the same order in which they appear.
A number \(n\) is considered prime if it has exactly two distinct positive divisors: 1 and \(n\) itself. Note that numbers less than or equal to 1 are not prime.
Example:
- Input:
7\n10 29 15 37 -3 17 23
- Output:
29 37 17 23
The input is provided via standard input and the filtered prime numbers should be printed to standard output separated by a single space. If there are no prime numbers in the list, output an empty line.
inputFormat
The first line contains a single integer \(n\) representing the number of integers in the list. The second line contains \(n\) space-separated integers.
For example:
7 10 29 15 37 -3 17 23
outputFormat
Print the prime numbers from the input list in the same order as they appear, separated by a single space. If there are no prime numbers, output an empty line.
## sample7
10 29 15 37 -3 17 23
29 37 17 23