C Programming Code Examples C > Mathematics Code Examples C Program to Check whether a given Number is Perfect Number C Program to Check whether a given Number is Perfect Number This C Program checks whether a given number is perfect number. Perfect number is a number which is equal to sum of its divisor. For eg,divisors of 6 are 1,2 and 3. The sum of these divisors is 6. So 6 is called as perfect number. #include <stdio.h> int main() { int number, rem, sum = 0, j; printf("Enter a Number\n"); scanf("%d", &number); for (j = 1; j <= (number - 1); j++) { rem = number % j; if (rem == 0) { sum = sum + j; } } if (sum == number) printf("Entered Number is perfect number"); else printf("Entered Number is not a perfect number"); return 0; }