Starting Vocational Training From 1-May-2024 Get Detail


Write a program in C to find the sum of the series 1!/1+2!/2+3!/3+4!/4+5!/5 using the function. 


#include <stdio.h>

int fact(int);
void main()
{
    int sum;
    sum=fact(1)/1+fact(2)/2+fact(3)/3+fact(4)/4+fact(5)/5;
    printf(" Function : find the sum of 1!/1+2!/2+3!/3+4!/4+5!/5 : ");
    printf("---------------------------------------------------------- ");    
    printf("The sum of the series is : %d ",sum);
}

int fact(int n)
    {
        int num=0,f=1;
        while(num<=n-1)
        {
            f =f+f*num;
            num++;
        }
    return f;
    }