Skip to content
C

Prime Checker Function

Easypython

Write a function is_prime(n) that returns True if n is a prime number, False otherwise, then read a number and print the result.

What the problem means: a prime number is a whole number greater than 1 with no divisors other than 1 and itself. Wrap that check inside a reusable function instead of writing it inline.

Approach: inside is_prime(n), return False for anything less than 2, then check whether any number from 2 up to n-1 divides n evenly.

Input: One line: a whole number n.

Output: One line: True or False.

Input (stdin)

Output

Run your code to see output here...