#C6170. Prime Number Filter
Prime Number Filter
Prime Number Filter
You are given a list of integers. Your task is to filter the list and output only the prime numbers in the order they appear.
A number \(n\) is considered prime if it satisfies the following condition:
\[ n > 1 \quad \text{and} \quad \nexists\, d \text{ such that } 1 < d < n \text{ and } d \mid n \]Implement an efficient algorithm to accomplish this task. Note that the input will be given via standard input (stdin
) and the output should be sent to standard output (stdout
).
inputFormat
The first line of input contains an integer \(n\) representing the number of integers in the list. The second line contains \(n\) space-separated integers.
outputFormat
Output all the prime numbers found in the list in the same order as they appear, separated by a single space. If there are no prime numbers, output an empty line.
## sample6
10 15 17 23 25 30
17 23