1952. Three Divisors

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1952

class Solution:
    def isThree(self, n: int) -> bool:
        cnt = 0
        i = 1
        while i <= n // i:
            if n % i == 0:
                cnt += 1 if i == n // i else 2
            i += 1
        return cnt == 3