-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Loops_2.java
More file actions
31 lines (29 loc) · 817 Bytes
/
Copy pathJava_Loops_2.java
File metadata and controls
31 lines (29 loc) · 817 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
30
31
/*We have a You are given q queries in the form of a,b , and n.
For each query, print the series corresponding to the given a,b ,
and n values as a single line of n space-separated integers.
the series is (a+2^0*b)(a+2^1*b)(a+2^n-1*b)
*/
import java.util.*;
class Java_Loops_2
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int q=sc.nextInt();
int a,b,sum,n;
for(int i=0;i<q;i++)
{
a=sc.nextInt();
b=sc.nextInt();
n=sc.nextInt();
sum=a;
for(int j=0;j<n;j++)
{
sum=sum+(int)Math.pow(2,j)*b;
System.out.print(sum+" ");
}
System.out.println();
}
sc.close();
}
}