Computer Science, asked by aisha5550, 1 year ago

Question 8
Write a program in Java to print the sum of the given series:​

Answers

Answered by vicky8764
0

Answer:

and where is the series....

Answered by 15aakashbest
1

Answer:

import java.util.Scanner;

public class Sum_Series

{

public static void main(String[] args)

{

double sum = 0;

int n;

System.out.println("1/1! + 2/2! + 3/3! + ..N/N!");

Scanner s = new Scanner(System.in);

System.out.print("Enter the no. of terms in series:");

n = s.nextInt();

Sum_Series obj = new Sum_Series();

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

{

sum = sum + (double)i / (obj.fact(i));

}

System.out.println("Sum of series:"+sum);

}

int fact(int x)

{

int mul = 1;

while(x > 0)

{

mul = mul * x;

x--;

}

return mul;

}

}

Output:

$ javac Sum_Series.java

$ java Sum_Series

1/1! + 2/2! + 3/3! + ..N/N!

Enter the no. of terms in series:5

Sum of series:2.708333333333333

Explanation:

please mark it as the brainliest

Similar questions