-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava Loops2.java
More file actions
29 lines (29 loc) · 761 Bytes
/
Copy pathJava Loops2.java
File metadata and controls
29 lines (29 loc) · 761 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
import java.util.Scanner;
import java.lang.Math; //to use Math.pow but that returns double only not integer!!
public class Forloop2
{
public static void main(String args[])
{
int a,b,n,q,i,j,sum,k,p;
Scanner reader = new Scanner(System.in);
q = reader.nextInt();
for(i=0;i<q;i++)
{
a = reader.nextInt();
b = reader.nextInt();
n = reader.nextInt();
sum=a;
for(j=0;j<n;j++)
{
p=1;
for(k=0;k<j;k++)
{
p=p*2;
}
sum = sum + (b*p);
System.out.print(sum + " ");
}
System.out.println("");
}
}
}