Loading...
Loading...
Loading...
A system only accepts prime ticket codes. Write is_prime(n) that returns True or False, and print Prime or Not prime. Numbers below 2 are not prime.
Prime or Not prime.Example 1
Input
97
Output
Prime
Nothing from 2 to 9 divides it.
Example 2
Input
100
Output
Not prime
Divisible by 2.
Try the problem first. Open one hint at a time.
Test divisors starting from 2. One exact divisor proves the number is not prime.
You never need a divisor larger than the square root: stop when d * d > n.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor