#include<stdio.h>
#include<conio.h>
int main(){
int n,i,sum=0;
clrscr();
printf("Enter an integer number\n");
scanf("%d",&n);
if (n>0){
for (i=1;i<n;i++) {
if (n%i==0)
sum=sum+i;
}
if (n==sum)
printf("%d is a perfect number.\n",n);
else
printf("%d is not a perfect number.\n",n);
}
getch();
return 1;
}
No comments:
Post a Comment