SImple 1-line python


  • 0
    D
    class Solution(object):
        def checkPerfectNumber(self, num):
            """
            :type num: int
            :rtype: bool
            """
            return (sum([(x if x != num else 0) + (num / x if x != num / x and x != 1 else 0) for x in range(1, int(num ** 0.5) + 1) if num % x == 0]) == num) if num > 0 else False
    

  • 0
    A

    @doraemon1293 could'nt get any more confusing than this! But still good job to post such a concise solution!!


Log in to reply
 

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