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
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