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/ Explanation:

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.

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad