You are viewing a single comment's thread. Return to all comments →
Easiest solution to the question. Juste understand the series and develop the formula i. e. Tn = a+b(2^n -1) . Now solve it easily :)
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a, b, n, q, c=1; q = sc.nextInt(); for(int i =1; i<=q; i++){ a= sc.nextInt(); b= sc.nextInt(); n= sc.nextInt(); c=1; for (int j = 1; j <= n; j++) { c*=2; System.out.print(a+b*(c-1)+" "); } System.out.println(); }
}
} `
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 →
Easiest solution to the question. Juste understand the series and develop the formula i. e. Tn = a+b(2^n -1) . Now solve it easily :)
} `