Computer Science, asked by anshikagupt, 7 months ago

Wap in java to find sum of given series using for loop
1+2+4+8+16+32.....n terms​

Answers

Answered by hoangmustang
1

Answer:

CHECK OUT MY SOLUTION

package newPack;

import java.util.*;

public class nTerm {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int a = input.nextInt();

int sum = 0;

int y = 1;

for(int i = 0; i < a; i++) {

 sum+=y;

 y*=2;

}

System.out.println(sum);

}

}

Explanation:

BRAINLIEST!

Similar questions