Skip to content
Home » Python program to check if a given number is a perfect or not in Python

Python program to check if a given number is a perfect or not in Python

Below is the Python program to check if a given number is a perfect or not in Python

A perfect number is a positive integer, which is equal to the sum of its divisors.

n=int(input("Enter number:"))
summ=0
for i in range(1,n):
    if (n%i==0):
        summ+=i
if (summ==n):
    print("The number", n, "is a Perfect number")
else:
    print("The number", n, "is not a Perfect number")

Output

Enter number:67

The number 67 is not a Perfect number