C Program to print the series sum : (1 / 1!) + (2 / 2!) + (3 / 3!)......upto n terms

 


// Program by Akash Tripathi (@proakash256)
 
#include <stdio.h>
unsigned long long factorial(int n)
{
    unsigned long long f = 1;;
    for(int i = ni >= 2i = i - 1)
        f = f * i;
    return f;
}
int main()
{
    int n;
    float s = 0;
    printf("Enter the number of terms upto which you want to 
print the series : ");
    scanf("%d" , &n);
    for(int i = 1i <= ni = i + 1)
    {
        unsigned long long f = factorial(i);
        s = s + (i / (float)f);
    }
    printf("\nThe Sum of the series upto %d terms is %0.2f" , n , s);
    return 0;
}

Comments