Prime checking
A number is considered prime if it’s only divisible by itself and by
1
(exactly two numbers).Implement a function
is_prime(n)
that would return True
if n
is prime and False
otherwise.The input contains a single integer
n
(1 ≤ n ≤ ).The program should print
Yes
if n
is prime and No
otherwise.Input | Output |
7 | Yes |
1 | No |
8 | No |
5 | Yes |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB