Java Loops II

  • + 0 comments

    class Solution{

        public int display(int n,int i){
        int mul;
        if(i == 0) {
            mul = 1;
            return mul;
        }else if(i == 1) {
            mul = 2;
            return mul;
        }else{
            mul = n * 2;
            return mul;
        }
    
    }
    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 total;
            int l = 2;
            Solution x = new Solution();
            for(int j = 0; j < n; j++){
                int m = x.display(l,j);
                total = a + m * b;
                System.out.printf("%d ",total);
                a = total;
                l = m;
            }
            System.out.println("");
        }
    }
    

    }