hacker rank java 7th problem solution


7.java loops II




  import java.util.*;
class papa{
  public static void main(String args[]){

    Scanner sn = new Scanner(System.in);
    int m= sn.nextInt();
    for(int i=0;i<m;i++){
      int sum=0;
      int a=sn.nextInt();
      int b=sn.nextInt();
      int n=sn.nextInt();
      for( int j=0;j<n;j++){
     double k=(Math.pow(2,j))*(int)b;
        sum += k;
        int sum1 = sum +a;
        System.out.print(sum1 +" ");
      }System.out.println();
      
    }
  }
}



Compiler Message
Success
Input (stdin)Download
2
0 2 10
5 3 5
Expected OutputDownload
2 6 14 30 62 126 254 510 1022 2046
8 14 26 50 98

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions