You are viewing a single comment's thread. Return to all comments →
Hi, this is my code, I hope it helps.
import java.util.*; import java.io.*; class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt(); int sum; int sum2; int p; for(int i=0;i<t;i++){ int a = in.nextInt(); int b = in.nextInt(); int n = in.nextInt(); sum = a + b; sum2 = 0; System.out.print(sum); for(p=1;p<n;p++){ sum2 = sum+(((int)Math.pow(2,p))*b); sum = sum2; System.out.print(" " + sum2); } if (t>1){ System.out.println(); } } in.close(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Loops II
You are viewing a single comment's thread. Return to all comments →
Hi, this is my code, I hope it helps.