Skip to content

Instantly share code, notes, and snippets.

@AbdullahMagat
Created July 27, 2018 23:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbdullahMagat/6df01b6d2b8ed0895c205f0ea862581a to your computer and use it in GitHub Desktop.
Save AbdullahMagat/6df01b6d2b8ed0895c205f0ea862581a to your computer and use it in GitHub Desktop.
Hackerrank Java Loops II
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
int res=a;
for(int j=0;j<n;j++){
res=res+b*(int)Math.pow(2,j);
System.out.print(res +" ");
}
System.out.println();
}
in.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment