Question
4. Fibonnaci Numbers The Fibonacci sequence is: 1; 1; 2; 3; 5; 8; 13; : : : The next Fibonacci number in the sequence is
4. Fibonnaci Numbers The Fibonacci sequence is: 1; 1; 2; 3; 5; 8; 13; : : : The next Fibonacci number in the sequence is obtained by adding the previous two elements in the sequence. In general we can generate Fibonacci-like sequences by making linear combinations of the formula that gives us the nth term of the sequence. Consider the following general case for generating Fibonacci-like sequences: F1 = 1 F2 = 1 Fn = aFn1 + bFn2 where a; b are integers. Write a function that given values a, b and n will print a Fibonacci-like sequece up to the nth term of the squence. (e.g., if a = 1, b = 2 and n = 7 the resulting sequence is 1; 1; 3; 5; 11; 21; 43) [HINT: Work out the recursion above by hand rst so you understand how the sequence is generated from a and b]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started