help with fibonacci program

i need help on writing a function that will prompt a user for n, and then calculate and return the n^th fibonnaci number by using recursion.

Comments

  • dude
    please read if there are other posts on the same subject b4 posting
    read the post by [red]" cooldudefido 2002-07-30 "[/red]
    -tyron

    : i need help on writing a function that will prompt a user for n, and then calculate and return the n^th fibonnaci number by using recursion.
    :

  • : i need help on writing a function that will prompt a user for n, and then calculate and return the n^th fibonnaci number by using recursion.
    :
    Try this function

    int fib(int n)
    {
    if(n < 3)
    return (n-1);
    return (fib(n-1)+fib(n-2));
    }



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories