- Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathjava-loops.java
More file actions
Latest commit
29 lines (26 loc) · 708 Bytes
/
Copy pathjava-loops.java
File metadata and controls
29 lines (26 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Java > Introduction > Java Loops II
// Use loops to find sum of a series.
//
// https://www.hackerrank.com/challenges/java-loops/problem
// challenge id: 8018
//
importjava.util.*;
importjava.io.*;
classSolution{
publicstaticvoidmain(String []argh){
Scannerin = newScanner(System.in);
intt=in.nextInt();
for(inti=0;i<t;i++){
inta = in.nextInt();
intb = in.nextInt();
intn = in.nextInt();
intx = a;
for (intj = 0; j < n; ++j) {
x += Math.pow(2, j) * b;
System.out.printf("%d ", x);
}
System.out.println();
}
in.close();
}
}