Is it prime?
Read a whole number n (at least 1) and print Prime if it is a prime number, otherwise Not prime.
A prime has exactly two divisors: 1 and itself. 1 is not prime.
Input
7
Expected output
Prime
Input
1
Expected output
Not prime
Show a hint
You only need to try divisors up to the square root of n: if n = a × b, one of a or b is at most √n.
Show a solution
Loading the editor…
Run the tests to check your solution.