C Program to find nth term of the series using recursion

C Program to find nth term of the series using recursion

#include
int get_term(int x);

int main()
{
    int n,p;
    printf("Enter which term do you want?\n");
    scanf("%d",&n);
    p=get_term(n);
    printf("T(%d) = %d\n",n,p);
    return 0;
}

int get_term(int x)
{
    int term;
    if(x==1)
      term=2;
    else
      term= get_term(x-1) + 1;
    return term;
}

No comments:

Post a Comment