Computer Applications
Write a program in Java to find the sum of the given series:
1 * 2 * 4 * 8 * ….. * 220
Java
Java Iterative Stmts
2 Likes
Answer
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

Answered By
3 Likes
Related Questions
Write a program in Java to find the sum of the given series:
Write a program in Java to find the sum of the given series:
1 + 3 + 7 + 15 + 31 + ….. + (220 - 1)
Write a menu driven class to accept a number from the user and check whether it is a Palindrome or a Perfect number.
(a) Palindrome number: (A number is a Palindrome which when read in reverse order is same as in the right order)
Example: 11, 101, 151 etc.
(b) Perfect number: (A number is called Perfect if it is equal to the sum of its factors other than the number itself.)
Example: 6 = 1 + 2 + 3
Write a program to print the sum of negative numbers, sum of positive even numbers and sum of positive odd numbers from a list of numbers entered by the user. The list terminates when the user enters a zero.