Computer Science - MATLAB

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.');
x=[a ones(1,100000)];
z=3;
while abs(x(z)/x(z-1)-x(z-1)/x(z-2))>0.001
x(z)=x(z-2)+x(z-1);
z=z+1;
end
g=x(find(x>1));

  1. 👍 0
  2. 👎 0
  3. 👁 24
asked by George

Respond to this Question

First Name

Your Response

Similar Questions

  1. Computer Science - MATLAB

    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

    asked by George on July 8, 2011
  2. maths! please help me it is an emergency!!!!!!!!!!

    what is the fibonacci sequence and what is its relationship to the golden ratio? http://www.google.com/search?q=fibonacci+golden+ratio&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official Many websites here

    asked by Kelly on September 16, 2006
  3. Pre-Calc

    Find three examples of the Fibonacci sequence in nature. Write a paragraph for each example. For each example, address the following questions: How does the example relate to the Fibonacci sequence? What portions of each item or

    asked by Anonymous on September 11, 2011
  4. Math (fibonacci

    A sequence of numbers is called a Fibonacci-type sequence if each number (after for the first two) is the sum of the two numbers which precede it. For example, 1, 1, 2, 3, 5, 8 ... is a Fibonacci- type sequence. If 1985, x, y, 200

    asked by Lexmo on August 8, 2014
  5. Sequences

    Like the Fibonacci sequence, a certain sequence satisfies the recurrence relation an=an−1+an−2. Unlike the Fibonacci sequence, however, the first two terms are a1=4 and a2=1. Find a32.

    asked by Daniel on February 9, 2018
  6. Maths

    A super-Fibonacci sequence is a list of whole numbers with the property that, from the third term onwards, every term is the sum of all the previous terms. For example, 1, 4, 5, 10, ... How many super-Fibonacci sequences with 1

    asked by Palmer on November 16, 2016
  7. Maths

    The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, ... starts with two 1s, and each term afterwards is the sum of its two predecessors. Which one of the ten digits is the last to appear in the units position of a number in the

    asked by AMT on November 18, 2016
  8. Math

    F25= 75,025 and F26= 121,393 where Fn is the nth term in the Fibonacci sequence. Find F27. I do not understand the Fibonacci sequence, could someone help me with my question and explain it to me please.

    asked by Punkie on December 6, 2009
  9. math

    The Fibonacci sequence of numbers begins 1,1,2,3,5,8,13,21,34,55,…and continues by the rule: every number is the sum of the two previous numbers. a. Determine the next five (eleventh through fifteenth) elements of this sequence.

    asked by bill on March 8, 2010
  10. math project...PLEASE HELP...

    I am doing a math project on Leonardo Fibonacci, the creator of the Fibonacci's Sequence. I was wondering if someone could please tell me a website where I could get more information about his marriage. can someone help me?

    asked by trixie on August 22, 2005

More Similar Questions