/съвършени числа/

Definition 1

Perfect Number is a positive integer that equals the sum of its divisors (except itself).

Definition 2

Perfect number is positive integer that is half the sum of all its divisors (including itself).

We don’t know:

  • if there are infinite number of perfect numbers
  • if there are any odd perfect numbers

C++:

int n = 1000;
int sum;
 
for (int i = 1; i < n; i++)
{
    sum = 0;
    for (int j = 1; j < i / 2; j++)
    {
        if (i % j == 0)
            sum = sum + j;
    }
    if (sum == i)
        cout << i << endl;
}