#K65947. Prime Number Filtering
Prime Number Filtering
Prime Number Filtering
Your task is to filter prime numbers from a given list of integers. A prime number is an integer greater than 1 that has no divisors other than 1 and itself. In this problem, you need to implement a prime-checking algorithm that uses the following logic: for an integer \( n \), if \( n \leq 1 \) then it is not prime; if \( n \leq 3 \) then it is prime; otherwise, if \( n \) is divisible by 2 or 3, it is not prime; and finally, for numbers greater than 3, check divisibility from 5 onward in increments of 6.
Given the list, output the prime numbers in the same order they appear, separated by a space.
inputFormat
The input consists of two lines:
- The first line contains a single integer \( n \), the number of elements in the list.
- The second line contains \( n \) space-separated integers.
outputFormat
Output a single line containing the prime numbers from the list separated by spaces. If no prime numbers are present, output an empty line.
## sample9
2 3 4 5 6 7 8 9 10
2 3 5 7