ICSE Class 10 Computer Applications
Question 43 of 69
Iterative Constructs in Java — Question 43
Back to all questions 43
Question Question 30(x)
Write a program in Java to find the sum of the given series:
1 * 2 * 4 * 8 * ..... * 220
public class KboatSeries
{
public static void main(String args[]) {
double sum = 0;
for (int i = 0; i <= 20; i++) {
double term = Math.pow(2,i);
sum += term;
}
System.out.println("Sum = " + sum);
}
}Output
