Question: MATLAB problems!! Write a recursive function to implement the definition of Fibonacci. The function will recieve one integer argument n, and it will return one

MATLAB problems!!

Write a recursive function to implement the definition of Fibonacci. The function will recieve one integer argument n, and it will return one integer value that is the nth Fibonacci number. Note that in this definition there is one general case but two base cases. Then test the function by printing (not for submission) the first 20 fibonacci numbers. This is what I did so far, and for some reason i keep getting errors

% QUESTION 4

% First 20 of Fibonacci series

n=1:20;

function fib = fibo(n)

fprintf('The first 20 values of the Fibonacci series are : %d',fib)

if n==0

fib=0;

elseif n==1

fib=1;

else

fib=fibonacci(n-1)+ fibonacci(n-2);

end

end

I just want to be able to see the result of the first 20 of the Fibonacci numbers. Can it please not come from the book solution. Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!