Perfect Numbers
public text v1 · immutable//This program lists all the perfect numbers less than a given positive integer(user input)
#include<iostream>
using namespace std;
main()
{
int n,m,i,sum=1;
cout << "List all the perfect numbers less than: ";
cin >> m;
for(n=2;n<m;n++)
{
for(i=n-1;i>1;i--)
{
if(n%i == 0)
sum += i;
}
if(sum == n)
cout << n <<endl;
}
}