27 lines
345 B
C++
27 lines
345 B
C++
|
#include<iostream.h>
|
||
|
int main()
|
||
|
{
|
||
|
int x,sum,a;
|
||
|
for(x=1;x<1000;x++)
|
||
|
{
|
||
|
sum=0;
|
||
|
for(a=1;a<x;a++)
|
||
|
{
|
||
|
if(x%a==0)
|
||
|
sum=sum+a;
|
||
|
}
|
||
|
if(sum==x)
|
||
|
{
|
||
|
cout<<x<<" its factors are ";
|
||
|
for(a=1;a<x;a++)
|
||
|
{
|
||
|
if(x%a==0)
|
||
|
cout<<a<<',';
|
||
|
}
|
||
|
cout<<'\n';
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|