#include<iostream.h>
void main ()
{
int num, fact, gfact, fsum=0;
cout << "ENTER A NUMBER : ";
cin >> num;
gfact=(num/2)+1;
for (fact=1; fact<=gfact; fact=fact+1)
{
if (num%fact==0)
fsum+=fact;
}
if (fsum==num)
cout << "\nIT IS A PERFECT NUMBER. " << endl;
else
cout << "\nIT IS NOT A PERFECT NUMBER. " << endl;
}
No comments:
Post a Comment