SHARE
TWEET

Question here: "https://ibb.co/g3VvCS"

Elanza48 Apr 14th, 2018 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5.  
  6.     private static ArrayList  terms = new ArrayList<Integer>();
  7.  
  8.     private static ArrayList aT =new ArrayList<Integer>();
  9.     private static ArrayList bT =new ArrayList<Integer>();
  10.     private static ArrayList nT =new ArrayList<Integer>();
  11.  
  12.     public static void main(String[] args){
  13.         String s="";
  14.         Scanner in = new Scanner(System.in);
  15.         /*
  16.         * numbers of terms to be entered together.
  17.         *
  18.         * for eg: user input ->
  19.         * 2
  20.         *0 2 10
  21.         *5 3 5
  22.         *
  23.         * */
  24.         int t=in.nextInt();
  25.         for(int i=0;i<t;i++){
  26.             aT.add(in.nextInt());
  27.             bT.add(in.nextInt());
  28.             nT.add(in.nextInt());
  29.         }
  30.         in.close();
  31.  
  32.         for(int i=0;i<t;i++){
  33.  
  34.             calcSeries((int)aT.get(i),(int)bT.get(i),(int)nT.get(i));
  35.             for(int o=0; o<terms.size();o++){
  36.                 System.out.printf("%d ",terms.get(o));
  37.             }
  38.             System.out.println(" ");
  39.         }
  40.  
  41.     }
  42.  
  43.     private static void calcSeries(int a, int b ,int n){
  44.         int temp;
  45.         terms.clear();
  46.         for(int i=0; i<n;i++){
  47.             temp =0;
  48.             for(int j=0; j<=i;j++){
  49.                 temp += Math.pow(2,j)*b;
  50.             }
  51.             terms.add(temp+a);
  52.         }
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top