We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I solved the problem but solution is different but I am getting the output which is specified in explanation.
import java.util.;
import java.io.;
import java.lang.Math;
class Solution{
public static void main(String []args){
Scanner in = new Scanner(System.in);
int a =in.nextInt();
int b =in.nextInt();
int n =in.nextInt();
int s=0;
s=s+a;
for(int i=0;i<n;i++){
s+=(Math.pow(2,i))*b;
System.out.print(" "+s);
}
}
}
Cookie support is required to access HackerRank
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 →
I solved the problem but solution is different but I am getting the output which is specified in explanation. import java.util.; import java.io.; import java.lang.Math;
class Solution{ public static void main(String []args){ Scanner in = new Scanner(System.in);
}