Java Loops II

  • + 0 comments
    public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int count = sc.nextInt();
            for (int i = 0; i < count; i++) {
                int[] nums = IntStream.range(0, 3).map(j -> sc.nextInt()).toArray();
                printResult(nums[0], nums[1], nums[2]);
            }
        }
    
        private static void printResult(int a, int b, int N) {
            int total = a;
            for (int i = 0; i < N; i++) {
                int pow = (int) Math.pow(2, i);
                total = total + pow * b;
                System.out.print(total + " ");
            }
            System.out.println();
        }