I want to find the number of the perfect numbers in a range. This is what i have done so far.
#include <iostream>
using namespace std;
int main()
{
// cout<<"Hello World";
int sum = 0;
int count = 0;
int x,y;
cout<<"Enter the first number";
cin>> x;
cout<<"Enter the second number";
cin>>y;
for(int i=x;i<=y;i++)
{
for(int j=1; j<i; j++)
{
if(i%j == 0)
{
sum=sum+j;
}
}
if(sum == i)
{
count++;
}
}
cout<<"The number of pefect numbers are: "<<count;
}
However when i enter ranges, it gives me that the number of the perfect numbers available within for example the range of 1 - 10 is 0.
Why is that? I can't figure out what is wrong here?