If the sum of all factors of a number ( exclusive itself ) is equal to the number, then the number is said to be perfect. E.g 6

Perfect number in Python

Steps to Check Perfect Number

  1. Take a number as input.
  2. Calculate the sum of all its factors(excluding itself)
  3. Check if the sum of its factors is equal to the input number.
  4. If YES then its a perfect number, else it is not.

Python Program

Output
Perfect number in Python

That’s all we need to write in order to check a perfect number in python. If you have any doubt’s then comment below.

Leave a Reply

Close Menu