Computer Science, asked by usingusers, 2 days ago

Write a program to find the sum of the following series:
S = 2/(1x)1 - 4/(3x)2 + 6/(5x)3 - ………… n terms

The Proper answer will be marked brainiest

Answers

Answered by Cahudary
1

Answer:

import java.util.Scanner;

public class KboatSeries

{

public void computeSum() {

Scanner in = new Scanner(System.in);

System.out.print("Enter n: ");

int n = in.nextInt();

double sum = 0.0;

for (int i = 1, j = 1; i <= n; i++, j = j + 2) {

double f = 1;

for (int k = 1; k <= i; k++) {

f *= k;

}

sum += j / f;

}

System.out.println("Sum=" + sum);

}

}

Similar questions