https://leetcode.com/problems/perfect-number/

Home   »   https://leetcode.com/problems/perfect-number/

# Approach #1: 나이브한 구현. time limit 에러
# Time complexity:
# Space complexity:

class Solution:
    def checkPerfectNumber(self, num: int) -> bool:
        divisors = []
        for i in range(1, num//2+1):
            if num % i == 0:
                divisors.append(i)
        return sum(divisors) == num

Leave a Reply

Your email address will not be published. Required fields are marked *