/* PERFECT NUMBER OR NOT */
#include<stdio.h>
#include<conio.h>
main()
{
int i=1,n,sum=0,temp;
clrscr();
printf("\n Enter n value: ");
scanf("%d",&n);
temp=n;
while(i<n)
{
if(n%i==0)
{
sum=sum+i;
}
i++;
}
if(temp==sum)
printf("\n The given number is perfect number %d ",temp);
else
printf("\n The given number is not a perfect number %d", temp);
getch();
}
No comments:
Post a Comment