Fibonacci sequence

This is a discussion on Fibonacci sequence within the C++ Programming forums, part of the General Programming Boards category; Im tryin to create a program that allows the user to input a number and it will find the corresponding ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    1

    Post Fibonacci sequence

    Im tryin to create a program that allows the user to input a number and it will find the corresponding fiboancci number that is that number in the sequence.

    ex.
    fib sequence 1 1 2 3 5 8 13 21 34

    user inputs : 6

    output : 8

    i was wonderin if someone could help me out Thanx!!

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    19
    This is loops, and this is also probably homework... so all I'm gonna tell you is that it involves one for loop inside of another for loop (if I recall from the last time I did this).. think about it.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    there is no need for nested loop. A single loop would work.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    3
    Code:
    /* deleted */
    Last edited by laserlight; 02-26-2008 at 08:24 AM.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,414
    lastdestined, read the Homework policy.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    3
    laserlight, sorry, I will respect the rules later.

    BTW, you can delete my message, I believe that guy haven't seen it yet

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    2,021
    It's also not a very good algorithm, as it can't count beyond 100 numbers, and because it store all the unneeded intermediate numbers. You really only need to store 3 numbers at a time, and there' no need to make an arbitrary limit like that.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fibonacci sequence
    By cph in forum C Programming
    Replies: 57
    Last Post: 04-30-2009, 07:17 AM
  2. n-th element of the fibonacci sequence
    By me001 in forum C Programming
    Replies: 22
    Last Post: 09-24-2008, 03:27 AM
  3. Fibonacci Sequence
    By Dogmasur in forum C Programming
    Replies: 15
    Last Post: 08-10-2008, 07:55 AM
  4. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 11:52 AM
  5. Fibonacci sequence output statement
    By chocha7 in forum C++ Programming
    Replies: 10
    Last Post: 11-18-2004, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21