0

Okay, I want to start off saying that yes this is a homework assignment but no I don't just want the answer for it. I actually want to learn how to work this. Having said that, I was assigned to determine whether a number is a perfect number and print all the perfect numbers from 1 - 1000. Here's what I have so far. I'm pretty positive that my flaw is in the factoriation loop.

```
#include <iostream>
using namespace std;
int isPerfect(int number)
{
int sum = 0;
int a = 0;
int factor = 0;
for(a = 1; a < number; a++)
{
if(number % a == 0) /* gets factorization */
factor = a;
}
sum = sum + factor;
if(sum == number)
cout << number << " is a perfect number" << endl;
}
int main()
{
int number = 0; /* number used for everything */
int i = 0; /*for loop variable */
for(i = 1; i < 1001; i++)
{
number = i;
isPerfect(number);
}
cout << endl << endl;
system("pause");
}
```