algorithms and the sequencing of numbers given a value The numbers in the table below are the result of executing an algorithm that has one parameter $n$, a non-negative integer, and produces sequences of integers as outputs. For values of $n$ from 0 to 5, the algorithm produces the following sequences of numbers as outputs:

$n = 0$: 0, 2.
$n = 1$: 3, 5, 7, 9.
$n = 2$: 6, 8, 10, 12, 14, 16.
$n = 3$: 9, 11, 13, 15, 17, 19, 21, 23.
$n = 4$: 12, 14, 16, 18, 20, 22, 24, 26, 28, 30.
$n = 5$: 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37.
$n = 6$: ?

I just started a course and I don't understand. I get the pattern differences and I understand all the patterns that are formed such as each outputs first number is a multiple of three and then the lists rise by two for each output given. When I put this down off of what I was given as a reference in the class it tells us to create an algorithm for this, but we have not been given but a few ways to do this so I tried:

$n^2-2\cdot0$ which would be $36-0=36$.
$n^2-2\cdot1$ which would be $36-2=34$.
$n^2-2\cdot2$ which would be $36-4=32$.
$n^2-2\cdot3$ which would be $36-6=30$.
$n^2-2\cdot4$ which would be $36-8=28$.
$n^2-2\cdot5$ which would be $36-10=26$.

So my outputs come out as 36, 34, 32, 30, 28, 26.
Is this correct? If not, where am I going wrong?
I don't see an algorithm in your answer. Also, I doubt that if you convert your sequence of steps into an algorithm, then it will produce the correct answer for $n=0,\ldots,5$.
From the given examples, you can see that the first number in the sequence is always $3n$, and from then on the numbers increase by $2$ each time (as you mention; but then in your &quot;algorithm&quot; they decrease by $2$ each time), and in total there are $2(n+1)$ of them (you can see this since the length of the sequence increases by $2$ each time).
How do we convert this into an algorithm? An algorithm is a recipe that prints the sequence for every value of $n$, not for the particular value $n=6$. Also, it should reproduce the given sequences for $n = 0,\ldots,5$.
Your question makes me doubt that the lecturer has explained the concept of &quot;algorithm&quot;, so instead, try to write a function in your favorite programming languages that given $n$, prints the sequence corresponding to $n$. Code is just a formal way of presenting an algorithm.