262,395 views
3 votes
3 votes
Q10. Consider the following algorithm:

g_1 = 9

g_2 = 5
Git
For k starting at 0 and ending with 8:
gk = (k-1)*gk-1 + gk-2

What is the last term, 8, of the recursive sequence generated as a result of
executing this algorithm?

User HackyStack
by
2.8k points

1 Answer

27 votes
27 votes

Answer:

61,940

Explanation:

For a recursive sequence of reasonable length, it is convenient to use a suitable calculator for figuring the terms of it. Since each term not only depends on previous terms, but also depends on the term number, it works well to use a spreadsheet for doing the calculations. The formula is easily entered and replicated for as many terms as may be required.

__

The result of executing the given algorithm is shown in the attachment. (We have assumed that g_1 means g[-1], and that g_2 means g[-2]. These are the starting values required to compute g[0] when k=0.

That calculation looks like ...

g[0] = (0 -1)×g[-1] +g[-2} = (-1)(9) +5 = -4

The attachment shows the last term (for k=8) is 61,940.

Q10. Consider the following algorithm: g_1 = 9 g_2 = 5 Git For k starting at 0 and-example-1
User Mohamed Desouky
by
2.9k points