#K1031. Filtering Prime Numbers
Filtering Prime Numbers
Filtering Prime Numbers
You are given a list of integers. Your task is to filter out the prime numbers and output them in the same order as they appear in the input.
A number \(n\) is called prime if it has exactly two distinct positive divisors: 1 and \(n\) itself. In other words, \(n > 1\) and for any integer \(a\) such that \(2 \leq a \leq \sqrt{n}\), \(n\) is not divisible by \(a\).
The input starts with an integer \(N\) which denotes the number of integers, followed by \(N\) integers separated by spaces or newline characters. Your program should output the prime numbers separated by a single space. If no primes are found, output an empty line.
inputFormat
The first line of input contains a single integer \(N\) (where \(0 \le N \le 10^5\)), which represents the number of elements in the list. The second line contains \(N\) space-separated integers. Each integer can be positive, negative, or zero.
outputFormat
Output a single line containing the prime numbers from the input list separated by a single space. If there are no prime numbers, output an empty line.
## sample7
2 4 5 6 9 11 13
2 5 11 13
</p>