Java Loops II

  • + 0 comments

    For Java15 Platform

    I wrote the code from scratch just to get more practice

    import java.util.Scanner;
    
    class Solution
    {
        public static void main(String args[])
        {
            Scanner sc = new Scanner(System.in);
            int q = sc.nextInt();
            
            for(int i=0; i<q; i++)
            {
                int a, b, n;
                a = sc.nextInt();
                b = sc.nextInt();
                n = sc.nextInt();
                
                int series = a;
                
                for(int j=0; j<n; j++)
                {
                    series += Math.pow(2, j) * b;
                    
                    System.out.print((int)series + " ");
                }
                
                System.out.print("\n");
            }
            
            sc.close();
        }
    }