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

3. (a) Fibonacci numbers are the numbers in a sequence in which the first two el

ID: 2257568 • Letter: 3

Question

3. (a) Fibonacci numbers are the numbers in a sequence in which the first two elements are 1 and 1, and the value of each subsequent element is the sum of the previous two elements: Write a MATLAB script that determines and displays the first 20 Fibonacci numbers. (b) The reciprocal Fibonacci constant y, is defined by the infinite sum where F, are the Fibonacci numbers, 1, 1, 2, 3, 5, 8, 13, ..Let Write a MATLAB script that calculates v, for a given n. Execute the program for n= 10, 100, and 1000.

Explanation / Answer

a)

clc;
clear all;
F(1)=1;
F(2)=1;

for i=2:19
F(i+1)=(F(i-1)+F(i));
end
F'

1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765

b)

n=10;

clc;
clear all;
F(1)=1;
F(2)=1;

for i=2:9
F(i+1)=(F(i-1)+F(i));
end

si=0;
for i=1:10
si=si+(1/F(i));
end
si

si =

3.3305

n=100

clc;
clear all;
F(1)=1;
F(2)=1;

for i=2:99
F(i+1)=(F(i-1)+F(i));
end

si=0;
for i=1:100
si=si+(1/F(i));
end
si

si =

3.3599

n=1000

clc;
clear all;
F(1)=1;
F(2)=1;

for i=2:999
F(i+1)=(F(i-1)+F(i));
end

si=0;
for i=1:1000
si=si+(1/F(i));
end
si

si =

3.3599

>>

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