# Perfect Number Or Not

## Perfect Number or not:-

A perfect number is a number which is equal to the sum of its divisors. For example, the divisors of 6 are 1, 2, and 3 whose sum is again 6. Therefore, 6 is a perfect number. The following algorithm and C program will test if a number is Perfect or not.

## Algorithm to test if a number is perfect or not:

Step 1. Start

Step 2. Input a number.

Step 3. Initialize the for loop from 1 to the given number.

Step 4. Add the value of sum in sum if number % i is equal to zero.

Step 5. Check the condition if the sum is equal to the number, it is a perfect number.

Step 6. Print “The number is Perfect”.

Step 7. Stop

Read Also: Program for Permutations in which N people can occupy R seats in a classroom

### C Program to check if a number is Perfect or not

```/* C Program to identify a Perfect Number */
# include <stdio.h>
int main()
{
int i, Num, sum = 0 ;
printf("\n Enter a number \n") ;
scanf("%d", &Num) ;
for(i = 1 ; i < Num ; i++)
{
if(Num % i == 0)
sum = sum + i ;
}
if (sum == Num)
printf("\n %d is a Perfect Number", Number) ;
else
printf("\n%d is not the Perfect Number", Number) ;
return 0 ;
}```

### Output

`Enter a number: 6`