Python 259ms, solution as per the docs....


  • 0
    A
    class Solution(object):
        def checkPerfectNumber(self, num):
            """
            :type num: int
            :rtype: bool
            """
            if(num<=0):
                return False
            l=[]
            for i in np.arange(1,np.sqrt(num)):
                if(num%i==0):
                    l.append(i)
                    l.append(num//i)
            if ((sum(l)-num)==num):
                return True
            else:
                return False
                
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.