152k views
5 votes
g The reciprocal Fibonacci constant ψ is defined by the infinite sum: ψ=∑n=1 [infinity] 1 Fn Where Fn 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. Start by setting the first two elements equal to 1, then Fn=Fn−1+Fn−2 . Write a MATLAB program in a script file that calculates ψ for a given n.

User Pndc
by
3.3k points

1 Answer

5 votes

Answer:

see explaination

Step-by-step explanation:

MATLAB script:

% MATLAB script that calculates reciprocal Fibonacci constant Ψ

% Initial Values

a0 = 1;

a1 = 1;

% Looping variable

i = 2;

% Reading n value from user

n = input(' Enter n value: ');

% Initializing sum

sum = (1/a0) + (1/a1);

% Loop till i reaches n value

while i <= n

% Finding term in Fibnocii series

a2 = a0 + a1;

% Accumulating Sum

sum = sum + (1/a2);

% Updating previous terms

a0 = a1;

a1 = a2;

% Incrementing loop variable

i = i + 1;

endwhile

% Printing result

printf("\\ Reciprocol Fibnocii Constant: %f \\", sum);

See attachment for sample output

g The reciprocal Fibonacci constant ψ is defined by the infinite sum: ψ=∑n=1 [infinity-example-1
User Ryan Russon
by
3.9k points