You are viewing a single comment's thread. Return to all 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(); }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Java Loops II
You are viewing a single comment's thread. Return to all comments →