#1952

Three Divisors

pupil · 345 · lc easy +22 · verified · 64% accepted · 634 likes · top 67%

Description

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

Example 1:

Input: n = 2
Output: false
Explantion: 2 has only two divisors: 1 and 2.

Example 2:

Input: n = 4
Output: true
Explantion: 4 has three divisors: 1, 2, and 4.

Code

1
2
3