Write a functio to check whether a number if perfect or not


Topic: Write a functio to check whether a number if perfect or not

Solution

def is_perfect(n):
    sum_ = 0
    for i in range(1, n//2 + 1):
        if n%i == 0:
            sum_+=i
    if sum_ == n:
        return True
    return False



List all Python Programs