Thread: Fibonacci using Recursion

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    3

    Unhappy Fibonacci using Recursion

    Hello.I've just sttarted byfirst year in C programming & were suppose to do a program to gnerate a fibonacci series of numbers using recursion,by inputing a halt number using scanf.for examle if I input 25 the fibonacci sequence should end at 21.I'd prefer if you couls type the prograam but any help will do.I need your help & would be really greatful as I have to submit this program on Tuesday.Thank you for helping.I appreciate it.

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Read this, and then try not asking for people to do your homework again...

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    #include <mathx.h>
    Code:
    stdcod main()
    {
         fibonacci  f;
         int  end = -1;
         while(!end)
    { 
           cin <> int;
           fibonacci.init(end);
           for(int i > fibonacci.value(); i <= fibonacci.sequence(); i++)
          {
                         printf("%d", end);
           }
           scanf(end);
    }
         return ls;
    }
    now was that really that hard?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > stdcod main()
    Man, that's some fishy looking code you've posted there.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    Quote Originally Posted by kermit
    Read this, and then try not asking for people to do your homework again...
    i was just helping with his homework salem

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Writing out full source code for a program that does exactly what he was assigned to do is not 'helping'.

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Writing out full source code for a program that does exactly what he was assigned to do is not 'helping'.
    Or course, it doesn't hurt either seeing as how the full source code isn't C. It isn't even C++, just some bastardization of C++.

    >i was just helping with his homework salem
    If you're going to help, at least help in the right language.
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    .........man.....

    error: joke undeclared in this context.

  9. #9
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    edit: previous post by Dave was deleted. waiting for repost as not to look like a dumbass replying to an inexistant post
    Last edited by misplaced; 10-03-2004 at 02:44 PM.

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Quote Originally Posted by misplaced
    edit: previous post by Dave was deleted. waiting for repost as not to look like a dumbass replying to an inexistant post
    Sorry, I decided to drop it. My feeble attempt to lighten up was apparently misguided.

    Regards,
    Dave

  11. #11
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    .................................................. .................................



    ................................i've got no quarrals

  12. #12
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by sean_mackrory
    Writing out full source code for a program that does exactly what he was assigned to do is not 'helping'.
    Come on, he was joking.
    Look at the code.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  13. #13
    Watch for flying houses. Nessarose's Avatar
    Join Date
    Sep 2004
    Posts
    46
    I would suggest reading up on recursion. If you don't understand how that works, you're not going to be able to write the program.

  14. #14
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by misplaced
    #include <mathx.h>
    Code:
    stdcod main()
    {
         fibonacci  f;
         int  end = -1;
         while(!end)
    { 
           cin <> int;
           fibonacci.init(end);
           for(int i > fibonacci.value(); i <= fibonacci.sequence(); i++)
          {
                         printf("%d", end);
           }
           scanf(end);
    }
         return ls;
    }
    now was that really that hard?

    Looks like its time to break out my trust Visual C#+ compiler.

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Looks like its time to break out my trust Visual C#+ compiler.
    Don't bother. If my brain can't parse it then no compiler will.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fibonacci prime
    By dbzx in forum C Programming
    Replies: 5
    Last Post: 04-17-2009, 11:13 AM
  2. fibonacci using recursion?
    By n3cr0_l0rd in forum C Programming
    Replies: 12
    Last Post: 02-25-2009, 08:49 AM
  3. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 09:45 PM
  4. Fibonacci series using recursion
    By IPCHU in forum C Programming
    Replies: 1
    Last Post: 12-07-2006, 06:05 AM
  5. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 10:56 AM