Tuesday, April 23, 2019

Java Loop


  1. import jaa.util.Scanner;

  2. public class LoopAlgorithm {
  3.     public static void main(String[] args) {
  4.         Scanner in = new Scanner(System.in);
  5.         int t = in.nextInt();
  6.         for (int i = 0; i < t; i++) {
  7.             int a = in.nextInt();
  8.             int b = in.nextInt();
  9.             int n = in.nextInt();
  10.             int result = 0;
  11.             for (int j = 0; j < n; j++) {
  12.                 if (j == 0) {
  13.                     result = (result +a + (int) (Math.pow(2, j) * b));
  14.                 } else {
  15.                     result = (int) Math.pow(2, j) * b;
  16.                     System.out.println(result+" ");
  17.                 }
  18.             }
  19.             System.out.print("");
  20.         }
  21.         in.close();
  22.     }
  23. }








No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...