اعداد کامل بین 1 تا 1000 را نشان دهد. مثالی از عدد کامل 1 + 2 + 3 = 6
#include<iostream>
#include<conio.h>
using namespace std;
bool perfect(int);
int main()
{
cout << "For the integers from 1 to 1000:\n";
for(int j = 2; j <= 1000; ++j)
if(perfect(j))
cout << j << " is perfect\n";
cout << endl;
getch();
return 0;
}
bool perfect(int value)
{
int factorSum=1;
for(int i=2; i <= value / 2; ++i)
if(value % i == 0)
factorSum += i;
return factorSum == value ? true : false;
}