#C12627. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
Given a list of integers, your task is to filter out the prime numbers and output them in the same order as they appeared in the list. A prime number is a natural number greater than 1 which has no positive divisors other than 1 and itself. In mathematical terms, a number \( n \) is prime if and only if \( n > 1 \) and for every integer \( i \) with \( 2 \leq i \leq \sqrt{n} \), we have \( n \mod i \neq 0 \).
If no prime numbers are found, output an empty line.
inputFormat
The first line contains a single integer \( n \) representing the number of elements in the list. The second line contains \( n \) space-separated integers.
outputFormat
Output the filtered prime numbers separated by a single space. If there are no prime numbers, output an empty line.
## sample8
10 15 3 7 19 24 5 11
3 7 19 5 11