0
Perfect Number
Program to check whether the given number is a perfect number or not?
1 Réponse
0
#Program to check whether the given number is a perfect number
def perfectnumber():
num=int(input("Enter a number\n"))
sum=0
for i in range(num):
if(i==0):
i=1
else:
if(num%i==0):
sum=sum+i
if(sum==num):
print("{0} is a perfect number".format(num))
else:
print("{0} is not a perfect number".format(num))
perfectnumber()