Ctrl K

A Trio of Divisors

Easy
You are given a positive integer n. A divisor of n is a positive integer d such that n is divisible by d with no remainder. Return true if n has exactly three distinct positive divisors, and false otherwise.
Example 1
n=49 → True

49 has exactly three divisors: 1, 7 and 49.

Example 2
n=12 → False

The divisors of 12 are 1, 2, 3, 4, 6 and 12, six in total.

Example 3
n=1 → False

1 has a single divisor.

Constraints
  • 1 ≤ n ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsCount Shared Divisors EasyWhere the Product Adds Up EasyPrimes Below a Bound MediumA Number as Two Primes MediumEven Vowel and Consonant Pieces Medium
loading Python…
Input
n=49
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 141 tests on the server, hidden ones included.