Title: Check whether the given number is Perfect
number or not
For example:
(i)
8 Factors 1,2,4,8
Except 8 add remaining all 1+2+4=7
8 is not a perfect number
(ii)
6 Factors 1,2,3,6
Except 6 add remaining all 1+2+3=6
6 is a perfect number
Program:
n=int(input("Enter n value\n"))
sum=0
for i in range(1,n):
if(n%i==0):
sum=sum+i
if(n==sum):
print(n," is perfect
number")
else:
print(n," is not perfect
number")
Output:
Enter n value
6
6 is
perfect
Comments
Post a Comment