Perfect numbers are positive integers which have the special property that the sum of all their factors equals the number itself, e.g., 6 = 1+2+3. The C program finds and prints out all perfect numbers less than 1000.
#define MAX 1000
long n, sum, j ,k, half;
printf("\n PERFECT NUMBERS\n");
sum = 0;
if(j%k==0) sum+= k;
printf("\r %7ld is a perfect number.\n", j);