Kernel
Widgets
Help
Trusted
Python 3
View
Insert
Cell
Code
Question 3: Calculating sequences (3 points)
You are given a numerical sequence that has the form 1, 1, 2, 4, 9, 21... Each successive number, after the first two, is found by adding twice the number before it and one less than the number before that. For example, the 7th number in the sequence is 2*21 + 9 - 1 = 50. A possibly useful hint: We might not have explicitly talked about it in class yet, but one really useful thing that Python allows you to do is index lists using negative numbers, which allows you to move backwards through the list as you increase the size of the negative number, starting with -1. That means that if I have the list stuff = [1, 23, 4], I can do stuff[-1] and I'll get the last number, 4. If I want the second to last number, I would do stuff[-2]. Your goal is to write a loop that computes 50 terms in the sequence. Store this sequence as a list and then print the list. You should get the following output: [1, 1, 2, 4, 9, 21, 50, 120, 289, 697, 1682, 4060, 9801, 23661, 57122, 137903, 433329, 803761, 1940450, 11309769, 27304197, 65918162, 159140520, 384199201, 927538921, 2239277042, 5406093004, 13051463049, 31509019101, 76069501250, 183648021600, 443365544449, 1070379110497, 2584123765442, 6238626641380, 15061377048201, 36361380737781, 87784138523762, 211929657785304, 511643454094369, 1235216565974041, 2982076586042450, 7199369738058940, 17380816062160329, 41961001862379597, 101302819786919522, 244566641436218640, 590436102659356801, 1425438846754932241]