If the sum of all factors of a number ( exclusive itself ) is equal to the original number then it’s a Perfect number.

Perfect Number in C

Steps to Check Perfect Number in C

  1. Input a number.
  2. Run a for loop less than the number ( say i ).
  3. In loop check, if i is a factor of the number. If yes, then add it to the sum.
  4. After the loop is over, Check if the resultant sum == number.
  5. If Yes, then the number is perfect, else Not.

C Program

Output of Program

C Program for Perfect Number

Output of Program

If this code works for you or you have any doubts regarding it, then do comment below.

Leave a Reply

Close Menu