Computer Science, asked by nikithacs3585, 1 year 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: N output 1103 2-4-3 0512 21 3 9-8-50 7 16 27 40 55 4-16-15 -12 -7 09 20 33 48 65 84 105 5-25 -24 -21 -16-9 0 11 24 39 56 75 96 119 144 171 Determine the algorithm that was used to generate the numbers in this table, and 1. Write it down. 2. 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.) Enter answer here

Answers

Answered by ashishsharma471
50

Answer:

-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