Computer Applications
Write a program to find the sum of first 20 terms of the series:
S = (2/3) + (4/5) + (8/7) + (16/9) + ----------
Java
Java Iterative Stmts
36 Likes
Answer
public class KboatSeriesSum
{
public static void main(String args[]) {
double sum = 0.0;
for (int i = 1, j = 3; i <= 20; i++, j += 2) {
sum += Math.pow(2, i) / j;
}
System.out.println("Sum = " + sum);
}
}
Variable Description Table
Program Explanation
Output

Answered By
17 Likes
Related Questions
Write a program to display the first ten terms of the series:
5, 10, 17, --------------
Write a program to display the given pattern:
1 1 1 1 1
3 3 3 3
5 5 5
7 7
9Write a program to display the given pattern:
3
5 6
8 9 10
12 13 14 15Write a program to input a number. Find the sum of digits and the number of digits. Display the output.
Sample Input: 7359
Sum of digits = 24
Number of digits = 4