My IsPerfect function aint working and I dont no where i went wrong.

```
bool IsPerfect(int num)
{
int sum = 0;
int x;
int divisor;
x = num;
while(x > 0)
{
divisor = x;
if(num % divisor == 0)
{
sum += divisor;
}
x--;
}
if(sum == num)
{
return true;
}
else
{
return false;
}
}
```