Perfect Number C Program
#include <stdio.h>
int main()
{
int n, s=0, i;
printf("Emter any number: ");
scanf("%d",&n);
for(i=1; i<n; i++)
{
if (n%i==0)
s=s+i;
}
if(n==s)
printf("%d is perfect number",n);
else
printf("%d is not perfect number",n);
return 0;
}
No comments:
Post a Comment