In the Fibonacci sequence, Fibonacci assumed that each rabbit took one month to mature. Now assume that
Question:
In the Fibonacci sequence, Fibonacci assumed that each rabbit took one month to mature. Now assume that rabbits taketwo month to mature. The sequence isdefined by
g0= 1, g1= 1, g2= 1 and for n > 2 gn= gn-1+ gn-3 sog3= 2
Write the MATLAB code for calculating the Fibonacci number with new conditions, using your code calculate how many pair of rabbits are there after 12 months (so g12)?
Assuming we are using the below functionto calculate Fibonacci numbers:
function f = fibnum(n) % FIBNUM Fibonacci number. % FIBNUM(n) generates the nth Fibonacci number. if n <= 1 f = 1; else f = fibnum(n-1) + fibnum(n-2); end
How many arithmetic, logical, and assignment operations do we need to calculate the nthFibonacci number, i.e. fibnum(n)? (assume each <= , = , + , - is such an operation). Note fibnum(0) == 1 here.
Use matlab notation with no whitespace and no assignment to enter your answer.
Question 3)
Following theprevious question, calculate how many operations you need for calculating fibnum(50). We recommend that you do not use scientific notation. Make sure that your answer is precise.