Dain1234 / Design-and-analysis-algorithm

0 stars 0 forks source link

Perfect number or not #25

Open Dain1234 opened 2 years ago

Dain1234 commented 2 years ago

include

int main() { int n,rem,sum=0,i; printf("enter the number="); scanf("%d",&n); for(i=1;i<n;i++) { rem=n%i; if(rem==0) { sum+=i; } } if(sum==n) printf("%d is a perfect number",n); else printf("%d isn't a perfect number",n);

}