n-th element of the fibonacci sequence

This is a discussion on n-th element of the fibonacci sequence within the C Programming forums, part of the General Programming Boards category; Originally Posted by me001 if n is negative code won't work. Correct. What about if n is very large? QuantumPete...

  1. #16
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by me001 View Post
    if n is negative code won't work.
    Correct. What about if n is very large?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  2. #17
    Registered User
    Join Date
    Sep 2008
    Posts
    25
    any nice free visual C compiler like Miracle C Compiler?

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,450
    any nice free visual C compiler like Miracle C Compiler?
    Frankly, for Windows, Visual C++ is the best, but if you found that has a learning curve that you dislike, then any other IDE would have a learning curve that you do not want to overcome. That said, Code::Blocks would be your next best bet.
    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

  4. #19
    Registered User
    Join Date
    Sep 2008
    Posts
    25
    thanks Code::Blocks is excellent

  5. #20
    Registered User
    Join Date
    Sep 2008
    Posts
    25
    If n is very large, code will run damm slow.
    This is not efficient code.

  6. #21
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,450
    If n is very large, code will run damm slow.
    This is not efficient code.
    Yes, though there is also a limitation in terms of the range of int.
    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

  7. #22
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by laserlight View Post
    Yes, though there is also a limitation in terms of the range of int.
    That's more what I was thinking of. Also, since this is a recursive function, you'll break the stack with sufficiently large n values.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  8. #23
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    To work nothing. It is fine

    EDIT: Just for practice, try writing the code using fewer lines. Then try to write the algorithm using more variables instead of recursion

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-25-2008, 12:50 AM
  2. Fibonacci Sequence
    By Dogmasur in forum C Programming
    Replies: 15
    Last Post: 08-10-2008, 07:55 AM
  3. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 11:52 AM
  4. Fibonacci sequence output statement
    By chocha7 in forum C++ Programming
    Replies: 10
    Last Post: 11-18-2004, 10:04 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

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