Write a Python function to check whether a given number is perfect number or not


Topic: Write a Python function to check whether a given number is perfect number or not

Solution

def perfect_number_checker(num):
    i = 2
    sum = 1
    while(i <= num//2 ) :
        if (num % i == 0) :
            sum += i
        i += 1
    if sum == num :
        return f'{num} is a perfect number'
    else :
        return f'{num} is not a perfect number'



List all Python Programs