Java Loops II

  • + 3 comments

    Here are the Easiest way Without Using any in-build function

    import java.util.Scanner;

    class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        int e = 1;
        for (int i = 0; i < time; i++) {
            int a = sc.nextInt(), b = sc.nextInt(), n = sc.nextInt();
            for (int j = 0; j < n; j++) {
                a = a + b * e;
                e *= 2;
                System.out.print(a + " ");
            }
            e = 1;
            System.out.println();
        }
        sc.close();
    }
    

    }