1952.三除数
1952.三除数
一、暴力法
改进
class Solution:
def isThree(self, n: int) -> bool:
i = 1
cnt = 0
while i * i <= n: #只需要遍历到根号n
if n % i == 0:
cnt += 1
if i * i != n: #两个因数不相等,则必然存在对称的
cnt += 1
i += 1
return cnt == 3最后更新于