You are viewing a single comment's thread. Return to all comments →
import java.util.; import java.io.; import java.lang.Math;
class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt(); for(int i=0;i
int tempResult = 0; int lastResult = 0; for(int j = 0; j < n; j++){ tempResult = func(j); lastResult = a + (b * tempResult); System.out.print(lastResult + " "); } System.out.println(); } in.close(); } // I use recursive function here public static int func(int i){ if(i>=0){ return (int) Math.pow(2, i) + func(i - 1); }else{ return 0; } }
}
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 →
import java.util.; import java.io.; import java.lang.Math;
class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt(); for(int i=0;i
}