Java Loops II

  • + 0 comments

    Java version: 15

    import java.io.*;
    import java.util.*;
    import java.lang.Math;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            Scanner scan = new Scanner(System.in);
            int r = scan.nextInt();
            for ( int i=0;i<r;i++){
                int a = scan.nextInt();
                int b = scan.nextInt();
                int n = scan.nextInt();
                int value = a;
                for(int j=0; j<n; j++){
                    value += (int)Math.pow(2,j) * b;
                    System.out.print(value + " ");
                }
                System.out.println();
            }
        }
    }