I am suppose to write a program that finds all the perfect numbers from 1 to 1000. When I try to run this program all I get is:

Perfect Numbers

Press any key to continue.......

I think the problem is in the prefect function, but i have gone thru this function over and over and it seems to me to be sound. But I have been wrong many times before, please help :confused:Code:`#include <iostream>`

using namespace std;

int perfect( int number );

int main()

{

int num = 1, answer;

cout << "Perfect Numbers" << endl;

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

{

answer = perfect( num );

if ( answer != 1 )

cout << answer << endl;

num++;

}

system("pause");

return 0;

}

int perfect( int a )

{

int num1, test0, test1, test2, test3 = 1, counter, divider = 1;

num1 = a;

test0 = num1 % 2;

if ( test0 == 0 )

counter = num1 / 2;

else

return 1;

for ( counter; counter >= 1; counter--)

{

test1 = num1 % divider;

if ( test1 == 0 )

{

test2 = num1 / divider;

test3 += test2;

}

divider++;

}

if ( test3 == num1 )

return num1;

else

return 1;

}