You are viewing a single comment's thread. Return to all comments →
If using Math.pow(), make sure you cast it to an integer since it returns a double.
import java.util.Scanner; class Solution{ public static void main(String [] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for (int i = 0; i < t; i++) { int a = scan.nextInt(); int b = scan.nextInt(); int n = scan.nextInt(); for (int j = 0; j < n; j++) { a += b * (int) Math.pow(2, j); System.out.print(a + " "); } System.out.println(); } scan.close(); } }
From my HackerRank Java solutions.
Seems like cookies are disabled on this browser, please enable them to open this website
Java Loops II
You are viewing a single comment's thread. Return to all comments →
Java solution - passes 100% of test cases
If using Math.pow(), make sure you cast it to an integer since it returns a double.
From my HackerRank Java solutions.