Computer Science, asked by suresh5035, 5 months ago

Create a class called Series which will contain

the following members function:

(i) long fact(int f) to find the factorial of f

and return it.

(ii) void sumSeries1(int x,int n) to calculate

and print the sum of the following

series: x+x/2!+x/3!+x/4!+...+x/n!

Answers

Answered by shashidubey1119
3

Answer:

// C program to get the sum of the series

#include <math.h>

#include <stdio.h>

  

// Function to get the series

double Series(double x, int n)

{

    double sum = 1, term = 1, fct, j, y = 2, m;

  

    // Sum of n-1 terms starting from 2nd term

    int i;

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

        fct = 1;

        for (j = 1; j <= y; j++) {

            fct = fct * j;

        }

        term = term * (-1);

        m = term * pow(x, y) / fct;

        sum = sum + m;

        y += 2;

    }

    return sum;

Similar questions