Java Loops II

  • + 0 comments
    import java.util.*;
    import java.io.*;
    
    class Solution{
        public static void main(String []argh){
            Scanner in = new Scanner(System.in);
            int t=in.nextInt();
            for(int i=0;i<t;i++){
                int a = in.nextInt();
                int b = in.nextInt();
                int n = in.nextInt();
                int two_component = 1;
                int term = a;
                for (int j=0;j < n; j++){
                    //term is ((2^(i) *b))
                    term +=  (two_component *b);
                    System.out.print(term+" ");
                    two_component = two_component << 1;
                }
                System.out.println();
            }
            in.close();
        }
    }