is_prime Function

Lab Python Beginner 10 points

Write is_prime(n) returning True/False. Read a line of integers and print only the primes, using your function.

Input

One line of integers.

Output

The primes on one line (empty line if none).

Example

Input

1 2 3 4 5 9 11 15 17

Output

2 3 5 11 17
Sample input available Sample output available
Editor
Python

Hints

Numbers below 2 are not prime.

return False as soon as you find a divisor.

Solution explanation

Returning early from inside a loop ends the whole function immediately.

Show solution
def is_prime(n):
    if n < 2:
        return False
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True


print(*[x for x in map(int, input().split()) if is_prime(x)])
Output
Answer
HOME LEARN COMMUNITY DASHBOARD