#K7791. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
You are given a list of integers. Your task is to filter and output only the prime numbers from the list while preserving the original order. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself, i.e., \(n > 1\) and for any integer \(d\) with \(1 < d < n\), \(d\) does not divide \(n\).
Input is provided via standard input (stdin) and output must be written 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 the prime numbers from the input list in the same order, separated by a single space. If no prime number is found, output an empty line.
## sample7
2 3 4 5 28 29 30
2 3 5 29