Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. [Collaborative] In mathematics, the Fibonacci numbers are the numbers in the

ID: 3674075 • Letter: 3

Question

3. [Collaborative] In mathematics, the Fibonacci numbers are the numbers in the following integer sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Given the initial first two numbers, each number in the sequence is defined as the summation of the previous two numbers. a. Write a MATLAB script that calculate and print the first n Fibonacci numbers using a loop of your choice. Set n = 20 in your script and submit this as example output. b. Explain why it is difficult to create the Fibonacci numbers using a vectorized command.

Explanation / Answer

N=input('Pick a number ');
fib=zeros(1,N);
fib(1)=1;
fib(2)=1;
k=3;
while k <= 20
fib(k)=fib(k-2)+fib(k-1);
k=k+1;
end

fprintf('The Fibonacci sequence to %d terms is ',N);
fprintf('%g ',fib);
fprintf(' ');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote