Computer Science, asked by ashishsharma471, 8 months ago

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:
Determine the algorithm that was used to generate the numbers in this table, and

Write it down.
Execute it for N = 6, and write down your result.
What is the sequence of numbers for N = 6?

(Give your answer as integers separated by single spaces.)

Answers

Answered by frozenPearl93
1

-36  -35  -32 -27 -20 -11 0 13 28 45 64 85 108 133 160 189 220 253

Explanation:

Here is the algorithm:

there are 3*N numbers in the row  

*  Squares the number N, then changes the sign... so -N^2

*  adds 1 to previous

*  adds 3 to previous

* adds 5 to previous

* adds 9 to previous

... continues to add the next consecutive odd # to previous

For N=6

-N^2 = -36 is the first number in the row sequence and there are 3*N = 18 numbers in the row

Then the following consecutive odds are added to each term  

      +1   +3   +5 +7 +9 +11+13+15+17+19+21+23 +25 +27+ 29 +31+33

so the 6th row is:

-36  -35  -32 -27 -20 -11 0 13 28 45 64 85 108 133 160 189 220 253

Similar questions