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