Write a python function to check whether a number is perfect


Topic: Write a python function to check whether a number is perfect

Solution

 def isPerfect( n ): 
     sum = 1
     i = 2
     while i * i <= n: 
         if n % i == 0: 
             sum = sum + i + n/i 
         i += 1
     return (True if sum == n and n!=1 else False) 



List all Python Programs