Results 1 to 3 of 3

Math Help - python - Fibonacci Sequence

  1. #1
    Newbie
    Joined
    Dec 2007
    From
    UK
    Posts
    23

    python - Fibonacci Sequence

    Hi,

    Im very confused about this question concerning the Fibonacci sequence:


    Implement an iterative Python function to generate numbers in the Fibonacci sequence:
    fib(0) = 1
    fib(1) = 1
    fib(n) = fib(n − 1) + fib(n − 2)

    Any help would be greatly appreciated!
    Attached Files Attached Files
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member
    Joined
    Jan 2008
    From
    UK
    Posts
    484
    Thanks
    66
    Quote Originally Posted by *skywalker* View Post
    Implement an iterative Python function to generate numbers in the Fibonacci sequence:
    fib(0) = 1
    fib(1) = 1
    fib(n) = fib(n − 1) + fib(n − 2)

    Any help would be greatly appreciated!
    n = ???
    a,b,c = 0,1,1
    while c<n:
    a,b,c=b,a+b,c+1
    print b

    This will display the nth term of the Fibonacci sequence and it's iteratve but it's not a function.

    You could ....put them in a list.....display them all...or whatever you want to do..

    By the way I can't read word documents.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Eater of Worlds
    galactus's Avatar
    Joined
    Jul 2006
    From
    Chaneysville, PA
    Posts
    3,001
    Thanks
    1
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Fibonacci sequence
    Posted in the Discrete Math Forum
    Replies: 5
    Last Post: April 6th 2010, 08:34 AM
  2. Fibonacci sequence
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: March 28th 2010, 04:54 AM
  3. Replies: 2
    Last Post: March 1st 2010, 12:57 PM
  4. Fibonacci sequence
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: September 26th 2009, 09:28 PM
  5. Fibonacci sequence
    Posted in the Algebra Forum
    Replies: 4
    Last Post: June 5th 2008, 12:15 AM

Search Tags


/mathhelpforum @mathhelpforum