To display whether the given number is perfect or not in Python

 PERFECT NUMBER

Perfect number, a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128.

CODING OF THE PROGRAM



num=int(input("Enter a number to check"))
divsum=0
for i in range(1,num):
       if num%i==0:
              divsum=divsum+i
if divsum==num:
       print(num, "is a perfect number")
else:
       print(num, "is not a perfect number")


OUTPUT  OF THE PROGRAM IN PYTHON
 

                                               THANK YOU😊

Comments

Popular posts from this blog

Program to find out whether a given number is prime number or not in python[using break statement]

How to display Floyd's triangle in python program

How to display BMI(Body mass index )using python program