HackerRank Java- Loops II
You are given q queries in the form of a, b, and n. For each query, print the series corresponding to the given a, b, and n values as a single line of n space-separated integers.
- import java.util.*;
- import java.io.*;
-
- class Solution{
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int t = scan.nextInt();
- for (int i = 0; i < t; i++) {
- int a = scan.nextInt();
- int b = scan.nextInt();
- int n = scan.nextInt();
- for (int j = 0; j < n; j++) {
- a += b * (int) Math.pow(2, j);
- System.out.print(a + " ");
- }
- System.out.println();
- }
- scan.close();
- }
- }