I'm writing a program to find all of the perfect numbers between 1 and 650. So I used a couple loops but the only output I'm getting is -
"0 is a perfect number"
Any help?
int main()
{
int x = 0;
while(x <= 650)
{
int sum = 0;
for(int y = 0; y < x; ++y)
{
if(x % y == 0)
{
sum = sum + y;
}
}
if(sum == x)
{
cout << x << " is a perfect number\n";
}
++x;
}