超出时间限制改进
28 = 1 + 2 + 4 + 7 + 14
循环从1到sqrt(28)
每次加上 i 和 num/i
比如 2 和 14
class Solution: def checkPerfectNumber(self, num: int) -> bool: import math if num <= 1: return False ans = 0 for i in range(1, int(math.sqrt(num)) + 1, 1): if num % i == 0: ans += i if i != 1 and num / i != i: ans += num / i return ans == num