#K40467. Find Prime Numbers from Array
Find Prime Numbers from Array
Find Prime Numbers from Array
You are given an array of integers. Your task is to identify and output all the prime numbers in the array in the order they appear. A prime number is defined as an integer greater than $1$ that has no divisors other than $1$ and itself.
Definition: A number $p$ is prime if and only if $p > 1$ and for every integer $a$ such that $2 \le a \le \sqrt{p}$, $a$ does not divide $p$.
If the array contains no prime numbers, output an empty line.
inputFormat
The input is read from stdin
. The first line contains a single integer $n$, which represents the number of elements in the array. The second line contains $n$ space-separated integers representing the array.
outputFormat
Print on stdout
the prime numbers from the array in the order they appear, separated by a single space. If there are no prime numbers, output an empty line.
5
2 3 5 7 11
2 3 5 7 11
</p>