Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Compute nth fibonacci term in C


//nth fibonacci term
#include<stdio.h> 
int fib(int n)
{
   if ( n <= 1 )
      return n;
   return fib(n-1) + fib(n-2);
}
 
int main ()
{
  int n ;
    printf("Enter Number to Compute nth Fibonacci Series");
    scanf("%d",&n);
  printf("\n%dth term of fibonacci series number is %d",n, fib(n));
 
  return 0;
}

Enter Number to Compute nth Fibonacci Series:
9
9th term of Fibonacci Series number is 34