Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- def get_list(num):
- result = [1]
- upper_bound = sqrt(num)
- i = 2
- while i < upper_bound:
- if num % i == 0:
- c = num // i
- if i != c and c != num:
- result += [i, c]
- else:
- result.append(i)
- i += 1
- return result
- class Solution:
- def checkPerfectNumber(self, num):
- """
- :type num: int
- :rtype: bool
- """
- if num <= 1:
- return False
- return num == sum(get_list(num))
Add Comment
Please, Sign In to add comment