Thread: help in recursion

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    35

    help in recursion

    hi frend i have to generate fibonacii sequence with and without recursion i did it without and also atemp to do with recursion but io dont know how to my atemp is
    Code:
    #include<stdio.h>
    #include<conio.h>
    cot(int i);
    main()
    {
    clrscr();
    int i;
    i=cot(3);
    printf("%d\t",i);
    getch();
    }
    cot(int i)
    {
    int m;
    if(i==0)return(0),
    m=cot(i-1)+i;
    return(m);
    }
    i know this is wrong code but plz tell me what can i do to make fabonacii sequence

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    int main()

    int cot(int i)

    f(n) = f(n-1)+f(n-2) where n >1
    f(0) = f(1) = 1
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    35
    i cant understand
    plz code it in to my prog

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    Quote Originally Posted by neha007
    plz code it in to my prog
    this is your job...

    what ecsactly you don't undestand?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 09:45 PM
  2. Recursion... why?
    By swgh in forum C++ Programming
    Replies: 4
    Last Post: 06-09-2008, 09:37 AM
  3. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 10:56 AM
  4. To Recur(sion) or to Iterate?That is the question
    By jasrajva in forum C Programming
    Replies: 4
    Last Post: 11-07-2001, 09:24 AM
  5. selection sorting using going-down and going-up recursion
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-02-2001, 02:29 PM