0

Perfect Number

Program to check whether the given number is a perfect number or not?

2nd Dec 2017, 7:27 AM
Mr. Prakhyath Rai
Mr. Prakhyath Rai - avatar
1 Answer
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()
2nd Dec 2017, 7:28 AM
Mr. Prakhyath Rai
Mr. Prakhyath Rai - avatar