Three Divisors
The problem is asking to check if the given integer n
has exactly three positive divisors.
Let’s solve this problem step by step:
If an integer
n
has exactly three divisors, it must be a square of a prime number. This is because a prime numberp
only has two positive divisors (1 and itself), andp^2
will add one more divisor which isp
, so it has three positive divisors in total.So, we first need to check if the given number
n
is a perfect square.Then, we need to check if the square root of
n
is a prime number.
Here’s the Python code implementing the above steps:


This code first calculates the square root of n
and checks if n
is a perfect square. If n
is not a perfect square, it returns False
. Then it checks if the square root of n
is a prime number. If the square root of n
is not a prime number, it returns False
. If it passed both checks, the function returns True
.