Programming Examples

Python program to check number is perfect number or not


perfect Number program in Python

Write a Python program which accept a integer number form user and check number is perfect or Not.

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

For instance, 6 has divisors 1, 2 and 3, and 1 + 2 + 3 = 6, so 6 is a perfect number.

Perfect Numbers between 1 to 10000 are:

6,28,496,8128

Solution:

num=int(input("Enter any Number : "))
sum=0
for a in range (1,num):
    if num%a==0:
        sum=sum+a
if sum==num:
    print(num ," is Perfect Number")
else:
    print(num ," is not a Perfect Number")

Output

Enter any Number : 7

7  is not a Perfect Number


========================

Enter any Number : 6

6  is Perfect Number


You can also Find: 

Python Program to Print First N Perfect Numbers.

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz