← Back to challenges

Exactly Three

PythonHardalgebramathnumbersvalidation

Instructions

You are given a number n. Determine whether n has exactly 3 divisors or not.

Examples

is_exactly_three(4) ➞ True
# 4 has only 3 divisors: 1, 2 and 4

is_exactly_three(12) ➞ False
# 12 has 6 divisors: 1, 2, 3, 4, 6, 12

is_exactly_three(25) ➞ True
# 25 has only 3 divisors: 1, 5, 25

Notes

1 ≤ n ≤ 10^12

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.