Examples Input

8 4 5 

Output

 8 12 16 20 24 public static Scanner in = new Scanner(System.in); public static PrintStream out = System.out; public static void main(String[] args) { int c=in.nextInt(); int b=in.nextInt(); int x=in.nextInt(); int a[]; a= new int [x]; for (int i=0;i<a.length;i++){ a[x]= (int) (c+ b); System.out.print(a.length); } } 

And how to make it so that the initial value of the progression is equal to int c

    1 answer 1

    There are two significant errors in your code:

    1. In the loop, the next calculated value of the progression is necessary where to write? - In a[i] , but not in a[x] . Because x is the original length of the array and it is constant.
    2. How is the i th term of an arithmetic progression calculated? - Its first element is taken and the difference of the progression multiplied by its i-1 element is added to it. You have an initial value of i=0 , so you can calculate a[i] as c + b*i .