Fibonacci sequence series program using recursion in C Language

The Fibonacci Sequence is the series of numbers as below :
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,………………

Here is the C Program to understand Fibonacci Series using recursion.

Recursion : If the function call it self then the function known as recursive function and the all process known as recursion.

Fibonacci Series Program:

#include<stdio.h>
#include<conio.h>
 
int Fibo(int);
 
main()
{
   int n, i = 0, c;
  printf("Enter Values:");
   scanf("%d",&n);
 
   printf("Fibonacci series:\n");
 
   for ( c = 1 ; c <= n ; c++ )
   {
      printf("%d\n", Fibo(i));
      i++;
   }
 
   return 0;
}
 
int Fibo(int n)
{
   if ( n == 0 )
      return 0;
   else if ( n == 1 )
      return 1;
   else
      return ( Fibo(n-1) + Fibo(n-2) );
}

The output of Fibonacci Series is :

Enter Values:  8

Fibonacci Series :
0, 1, 1, 2, 3, 5, 8, 13

 

Leave a Reply

Your email address will not be published. Required fields are marked *