#C13969. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
Given a list of integers, your task is to filter out and output all the prime numbers in the same order they appear in the input. Recall that a prime number \(n\) is defined as a positive integer greater than 1 that has no positive divisors other than 1 and itself. A typical method for checking if a number \(n\) is prime is to test divisibility from 2 up to \(\sqrt{n}\). Use this concept to design your solution.
inputFormat
The input consists of two lines. The first line contains a single integer (n), representing the number of elements in the list. The second line contains (n) integers separated by spaces.
outputFormat
Output the prime numbers from the input list, preserving their original order. If there are multiple prime numbers, print them on one line separated by a single space. If no prime numbers are found, output an empty line.## sample
9
10 15 3 7 19 22 23 25 29
3 7 19 23 29