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?