# C program to find the perfect number

In this tutorial, we will see about perfect number in C.

Perfect number is the postive number which is equal to the sum of all its divisors excluding itself.

**For example:**

28 is a perfect number because

Divisors of 28 are: 1,2,4,7 and 14 and its sum is equal to 28(1+2+4+7+14)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include<stdio.h> int main(){ int number,j,sum=0; printf("Enter a number:"); scanf("%d",&number); for(j=1;j<=number/2;++j){ if(number%j==0){ sum=sum+j; } } if(sum==number){ printf("%d is Perfect Number",number); } else{ printf("%d is not perfect number",number); } return 0; } |

**Output:**

Enter a number:28

28 is Perfect Number

28 is Perfect Number

Enter a number:35

35 is Perfect Number

## Explanation

You just need to find the divisors of number and check if sum of divisors is equal to the number or not.

That’s all about perfect number in c.