Fibonacci using Recursion

This is a discussion on Fibonacci using Recursion within the C Programming forums, part of the General Programming Boards category; Hello.I've just sttarted byfirst year in C programming & were suppose to do a program to gnerate a fibonacci series ...

  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,528
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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,796
    >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,796
    >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.

Page 1 of 2 12 LastLast
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, 07:49 AM
  3. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 08:45 PM
  4. Fibonacci series using recursion
    By IPCHU in forum C Programming
    Replies: 1
    Last Post: 12-07-2006, 05:05 AM
  5. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 09:56 AM

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