## Introduction

Fibonacci Series in C:- Fibonacci series is a series of numbers in which the next number is the sum of the previous two numbers for *eg:- 0,1,1,2,3,5,8,13,21 *etc

The first Fibonacci numbers are 0 and 1 respectively

**F(N) = F(N - 1) + F(N - 2)**

The above expression is the general equation followed by every Fibonacci number.

Two main approaches for printing the Fibonacci series in C are-

**Fibonacci Series using recursion****Fibonacci Series without recursion**

## Fibonacci Series Using Recursion in C

We can get the Fibonacci series in C using the recursive approach. To print the Fibonacci series in C language using __recursion__. We can define a recursive function to perform this task.

We can define a recursive function that takes an integer **n **as an argument and returns the nth Fibonacci number.

In the recursive function, the base conditions are when n is either 0 or 1, representing the first and second terms of the Fibonacci series. Any other tern is calculated by making a recursive call for the lower values since the nth Fibonacci numbers depend upon the value of (n-1)th and (n-2)th Fibonacci term.

**Program to find fibonacci series in c using recursion:**

```
// Including Header Files
#include<stdio.h>
//Recursive function to get the nth Fibonacci number
int nthFibonacci(int n){
// Base Condition
if(n<=1){
return n;
}
// Using the relation- F(N)=F(N-1)+F(N-2)
return nthFibonacci(n-1)+nthFibonacci(n-2);
}
int main() {
// The number of terms in the Fibonacci Series we want to output
int n;
printf("Enter the numbers of terms in the Fibonacci Series\n");
scanf("%d",&n);
printf("The first %d numbers in the Fibonacci Series are \n",n);
//Running a for loop for n times.
for(int i=0;i<n;i++){
//Storing the (i+1)th Fibonacci term
int curr=nthFibonacci(i);
printf("%d ",curr);
}
}
```

**Output**

```
Enter the numbers of terms in the Fibonacci Series
10
The first 10 numbers in the Fibonacci Series are
0 1 1 2 3 5 8 13 21 34
```

**Explanation**

We define a recursive function** nthFibonacci**, it takes an integer **n **as an argument and returns the nth Fibonacci number. We take input from the user and store it in variable **n**. We make this function call inside a for loop which runs for n times. In the ith iteration, the **nthFibonacci **function will return the ith Fibonacci term.

In the recursive function, the base conditions are when n is either 0 or 1, representing the first and second terms of the Fibonacci series. Any other tern is calculated by making a recursive call for the lower values since the nth Fibonacci numbers depend upon the value of (n-1)th and (n-2)th Fibonacci term.