#include<stdio.h>
main()
{
int num,temp,sum=0,i=1;
printf("\nEnter a number=");
scanf("%d",&num);
temp=num;
while(i<=num/2)
{
if(num%i==0)
sum=sum+i;
i++;
}
if(temp==sum)
printf("\n%d is a perfect number",temp);
else
printf("\n%d is not a perfect number",temp);
}
main()
{
int num,temp,sum=0,i=1;
printf("\nEnter a number=");
scanf("%d",&num);
temp=num;
while(i<=num/2)
{
if(num%i==0)
sum=sum+i;
i++;
}
if(temp==sum)
printf("\n%d is a perfect number",temp);
else
printf("\n%d is not a perfect number",temp);
}
No comments:
Post a Comment