Tuesday, March 5, 2024

32.Sum of all factors :—

 32.Sum of all factors :—


#include<stdio.h>

int main()

{

    int i,n,r,sum;

    printf("enter a value of n ");

    scanf("%d",&n);

    sum=0;

    for(i=1;i<=n;i++)

    {

        r=n%i;

        if(r==0)

        {

            sum=sum+i;

        }

    }

    printf("%d",sum);

    return 0;

}


No comments:

Post a Comment