Three Divisors

Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.

An integer m is a divisor of n if there exists an integer k such that n = k * m.

Example 1
Inputn = 2
Outputfalse
2 has only two divisors: 1 and 2.
Example 2
Inputn = 4
Outputtrue
4 has three divisors: 1, 2, and 4.

Constraints

  • 1 <= n <= 10^4

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate