#C12502. Filter Prime Numbers

    ID: 41937 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

In this problem, you are given a list of integers and your task is to filter out the prime numbers. A prime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself. In mathematical terms, an integer ( n ) is a prime if for every integer ( d ) such that ( 2 \leq d \leq \sqrt{n} ), we have ( n \mod d \neq 0 ). Implement a helper function to determine if a number is prime and then use it to filter the list. The order of the numbers in the output must be the same as the input.

inputFormat

The input consists of a single line containing space-separated integers.

outputFormat

Output the prime numbers extracted from the list in the same order as they appear in the input. The numbers should be printed on one line separated by a single space. If there are no prime numbers, output an empty line.## sample

12 15 7 5 8 17
7 5 17