// // Created by Paul on 2016/4/20. // #include "iostream" int isPerfectNumber(int n);
int main(){ for(int i = 1;i < 10000;i ++){ int flag = isPerfectNumber(i); if(flag == 1){ printf("%d \n",i); } } }
int isPerfectNumber(int n) { if(n < 6)return0; int i = 2; int sum = 1; while(i < n/2 + 1){ if(n % i == 0)sum += i; i ++; } if(sum == n)return1; elsereturn0; }