#include<stdio.h>
int sum_factor(int m)
{
int i=1,sum=0;
while(i<=m)
{
if(m%i==0)
{
sum=sum+i;
}
i++;
}
return sum;
}
main()
{
int n;
printf("\nEnter the number=");
scanf("%d",&n);
printf("Sum of the factors of %d=%d",n,sum_factor(n));
}
int sum_factor(int m)
{
int i=1,sum=0;
while(i<=m)
{
if(m%i==0)
{
sum=sum+i;
}
i++;
}
return sum;
}
main()
{
int n;
printf("\nEnter the number=");
scanf("%d",&n);
printf("Sum of the factors of %d=%d",n,sum_factor(n));
}
No comments:
Post a Comment