Welcome to Westonci.ca, where curiosity meets expertise. Ask any question and receive fast, accurate answers from our knowledgeable community. Get quick and reliable solutions to your questions from a community of experienced experts on our platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
Sagot :
In this exercise we have to use the knowledge in computational language in python to write the following code:
We have the code can be found in the attached image.
So in an easier way we have that the code is:
function v = myfib(n,v)
if nargin==1
v = myfib(n-1,[0,1]);
elseif n>1
v = myfib(n-1,[v,v(end-1)+v(end)]);
end
end
function v = myfib(n,v)
if nargin==1
v = myfib(n-1,[0,1]);
elseif n>1
v = myfib(n-1,[v,v(end-1)+v(end)]);
elseif n<1
v = 0;
end
function [n] = abcd(x)
if (x == 1 || x==0)
n = x;
return
else
n = abcd(x-1) + abcd(x-2);
end
end
fibonacci = [0 1];
for i = 1:n-2
fibonacci = [fibonacci fibonacci(end)+fibonacci(end-1)];
end
>> myfib(8)
ans =
0 1 1 2 3 5 8 13
>> myfib(10)
ans =
0 1 1 2 3 5 8 13 21 34
See more about python at brainly.com/question/18502436
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.