Hello! Tell me how to create an algorithm for the task where to start?

Create a program that displays the first 12 elements of the sequence.
2a n + 1 = 2a n -2–2, where a 1 = 3 and a 2 = 2.

UPD
without using an array

    4 answers 4

    Take three variables: A1, A2, A3.

    1. A1 = 3
    2. A2 = 2
    3. A3 = f (A2, A1)
    4. Withdraw A3
    5. A1 = A2, A2 = A3
    6. Repeat from step 3 until you reach the desired item.
    • There is a tick to accept the answer you like - knes
    • No, I just clicked once and I didn’t think that after clicking, the page should be updated - turtles
    • After clicking there tick appears. By the way, now there as a result, none have been accepted ... =) - knes

    It is necessary to begin, obviously, with a cycle.

    int a = 3; for (int number = 1; number <= 12; number++) { a = (2*a-4); System.out.println(a); } 

    Whit. Syntax Java. I apologize if I give an error: I did not miss it at all. =) But I think you only need a principle? ;)

    UPD will output 12 elements, but up to the thirteenth (a2-a13) since a1 is already set.

     for (int number = 1; number < 12; number++) { 

    So - 12

      Sending a class that solves this problem using a recursive formula:

       public class Test { private static int f(int x) { if (x == 1) { return 3; } else if (x == 2) { return 2; } else { return 2 * f(x - 2) - 2; } } public static void main(String[] args) { for (int i = 1; i <= 12; i++) { System.out.println(i + " : " + f(i)); } } } 

      I hope that the solution will suit you.

      Sincerely, Eugene.

          int a1=3, a2=2, a3=0; for (int i=1; i<=12; i++) { a3 = 2*a1-2; System.out.print(a3 + " "); a1=a2; a2=a3; }