Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Main {
- private static ArrayList terms = new ArrayList<Integer>();
- private static ArrayList aT =new ArrayList<Integer>();
- private static ArrayList bT =new ArrayList<Integer>();
- private static ArrayList nT =new ArrayList<Integer>();
- public static void main(String[] args){
- String s="";
- Scanner in = new Scanner(System.in);
- /*
- * numbers of terms to be entered together.
- *
- * for eg: user input ->
- * 2
- *0 2 10
- *5 3 5
- *
- * */
- int t=in.nextInt();
- for(int i=0;i<t;i++){
- aT.add(in.nextInt());
- bT.add(in.nextInt());
- nT.add(in.nextInt());
- }
- in.close();
- for(int i=0;i<t;i++){
- calcSeries((int)aT.get(i),(int)bT.get(i),(int)nT.get(i));
- for(int o=0; o<terms.size();o++){
- System.out.printf("%d ",terms.get(o));
- }
- System.out.println(" ");
- }
- }
- private static void calcSeries(int a, int b ,int n){
- int temp;
- terms.clear();
- for(int i=0; i<n;i++){
- temp =0;
- for(int j=0; j<=i;j++){
- temp += Math.pow(2,j)*b;
- }
- terms.add(temp+a);
- }
- }
- }
Add Comment
Please, Sign In to add comment