Discover the answers to your questions at Westonci.ca, where experts share their knowledge and insights with you. Experience the convenience of getting accurate answers to your questions from a dedicated community of professionals. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly 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
Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.