Editor

Prime or Not

Programs with input · Intermediate · about 7 min

Read a whole number and print whether it is prime, as 29 is prime or 21 is not prime. A prime number is greater than 1 and can be divided exactly only by 1 and itself, so 0, 1 and negative numbers are not prime.

The prompts inside input() are not checked, only what you print.

Examples

You type:

29

The program prints:

29 is prime

You type:

21

The program prints:

21 is not prime
n = int(input("Number: "))
# Print whether n is prime
The solution opens after your first Check.