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.
hi guys below is my code i'm not getting the output please correct me
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
int size=n-1;
int su=a;
if(a>=0 && b>=0 && n>0){
for(int i=0;i<=size;i++){
int power= (int)Math.pow(2,i);
su=su+power*b;
System.out.format("%d ",su);
}
System.out.println();
}
in.close();
}
Java Loops II
You are viewing a single comment's thread. Return to all comments →
public static void main(String []argh){ Scanner in = new Scanner(System.in);