Fibonacci series using recursion: To print the Fibonacci series this is implemented using recursion in c.

Recursion in c :
It is a process where function calls itself directly or indirectly.

What is Fibonacci?
Fibonacci series is a collection or set of the numbers starting with zero or one, followed by the sum of two preceding numbers.
Consider Fibonacci series till N which is implemented as 0,1,(0+1),(0+2)…. N.

Example :
Write a Fibonacci series up to 8 numbers.
0,1,1,2,3,5,8,13.
we calculated this series as first two number as 0 and 1 , 0+1 => 1, 1+2=>3 ,3+2=>5,5+3=>8,8+5=>13

Page Contents

## Fibonacci algorithm

1. Write a recursive function to find the Fibonacci series. fib(int)
2. Write the main
3. Declare variable. N
4. Take a number from user. N
5. Pass Number and call recursive function. fib(n)
6. Find Fibonacci series in function
7. Print Fibonacci series.

## C program for Fibonacci series using recursion

```#include<stdio.h>

int fibonacci(int n)
{
if((n==1)||(n==0))
{
return(n);
}
else
{
return(fibonacci(n-1)+fibonacci(n-2));
}
}

int main()
{
int n,i=0;
printf("Input the number of terms for Fibonacci Series:");
scanf("%d",&n);
printf("\nFibonnaci Series is as follows\n");
while(i<n)
{
printf("%d ",fibonacci(i));
i++;
}

return 0;
}```

Output : 