Computer Science - MATLAB
posted by George .
I guess it was skipped
One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approach a number called “the golden ratio” or PHI. Create a program that accepts the first two numbers of a Fibonacci sequence as a user input and then calculates additional values in the sequence until the ratio of adjacent values converges to within 0.001. You can do this in a WHILE loop by comparing the ratio of element k to element k-1 and the ratio of element k-1 to element k-2. If you call your sequence x, then the code for the WHILE statement is
while abs(x(k)/x(k-1) – x(k-1)/x(k-2))>0.001
I think I'm doing something wrong... Here's my attempt at a solution
a=input('Please enter the first two numbers of the Fibonacci sequence in "[# #]" form. Do not enter [0 1] or [1 1]. Your free to enter anything else though.');