The reciprocal Fibonacci constant is defined by the infinite sum: psi = sigma^in
ID: 3120965 • Letter: T
Question
The reciprocal Fibonacci constant is defined by the infinite sum: psi = sigma^infinity_n = 1 1/F_n Where F_n are the Fibonacci numbers 1, 1, 2, 3, 5, 8, 13, Each element in this sequence of numbers is the sum of the previous two. Write a MATLAB program in a script file that calculates the first hundred Fibonacci numbers F_n. Start by setting the first two elements in F_n series equal to 1, then determine the series F_n up to n = 100. Then find the value of the constant psi for n = 10 to 100 with an increment of 10. The program must display the result using fprintf as: The Fibonacci constant for n = XXX is XXXXX The Fibonacci constant for n = XXX is XXXXX where XX is the value of n used and XXXX is the value of the constant psi up displayed in f format with 15 decimal digits. hat do you conclude from your results?Explanation / Answer
function f = fibo(n)
if n == 1 || n == 2
f = 1;
else
f = fibo(n-1) + fibo(n-2);
end
function f = sumall(n)
count = 0;
for c = 1:n
count = count + 1/fibo(c);
end
end
for c = 10:100 :10
fprintf("The Fibonacci Constant for n = %d is %17.15f ",c,sumall(c));
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.