0

I am trying to write a C++ program that will list the perfect numbers between 1 and 1000. I also have to print the divisors to confirm the number is perfect. I started by trying to find the perfect numbers. Here is my code. Please help.

#include <iostream>

using std::cout;

int Perfect (int number)

{

int sum = 0;

for (int i = 1; i <= number; i++)

{

if (number % i == 0)

{

sum = sum + i;

}

}

if (sum == number)

{

cout<<sum<<" is a perfect number";

}

return 0;

}

int main()

{

for (int i = 1; i <= 1000; i++)

{

Perfect(i);

}

return 0;

}