#C12833. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
You are given a list of integers. Your task is to filter out the prime numbers from the list. A number \(n\) is said to be prime if and only if \(n > 1\) and it has no positive divisors other than 1 and itself. In other words, if \(n > 1\) and for every integer \(d\) with \(2 \leq d \leq \sqrt{n}\), \(d\) does not divide \(n\), then \(n\) is prime.
The input consists of an integer \(n\) followed by \(n\) integers. Your program should output all the prime numbers present in the input sequence, preserving their order, with a single space separating them. If no prime number is found, output an empty line.
inputFormat
The first line contains a single integer \(n\) (the number of elements). The second line contains \(n\) integers separated by spaces.
outputFormat
Output a single line containing all the prime numbers from the input list separated by a single space. If there are no prime numbers, output an empty line.
## sample9
2 3 4 5 6 7 8 9 10
2 3 5 7