# Fibonacci series in C using recursion

Dive into the fascinating world of the Fibonacci series, a cool math sequence! Ever wondered how it magically appears in code? This blog explores a special way – using recursion. Imagine a function that talks to itself, helping create the Fibonacci series. We’ll uncover this cool concept called recursion, where functions can call themselves, and we’ll learn a trick to avoid talking forever by setting a base case. Get ready for a coding adventure!

```// Fibonacci series in c using recursion
#include<stdio.h>
int Fibonacci(int);
int main()
{
int num, i = 0, c;
scanf("%d",&num);
printf("Fibonacci series:\n");
for ( c = 1 ; c <= num ; c++ ){
printf("%d\n", Fibonacci(i));
i++;
}
return 0;
}
int Fibonacci(int num){
if ( num == 0 )
return 0;
else if ( num == 1 )
return 1;
else
return ( Fibonacci(num-1) + Fibonacci(num-2) );
}```

Explore the fascinating world of Fibonacci series in C using while loop Check out!

Explanation of the Code:

This C program generates the Fibonacci series using recursion. The `main` function prompts the user to input the number of terms in the series (`num`).

It then iterates through a loop, printing each term of the Fibonacci series by calling the `Fibonacci` function.

The `Fibonacci` function defines the base cases (returning 0 for `num` equal to 0 and 1 for `num` equal to 1) and recursively calculates the subsequent terms.

The program continues until the desired number of terms is printed. Recursion allows for a concise and elegant implementation, breaking down the problem into smaller, solvable components.

Learn How to Generate Fibonacci series in C using for loop, Now!

#### Output:

``````Enter the number of terms in the Fibonacci series: 5
Fibonacci series up to 5 terms:
0 1 1 2 3``````

Comparison with Other Methods

Know the Fibonacci Series in Python Using For Loop here!

In conclusion, exploring the Fibonacci series through recursion adds a touch of elegance to the coding journey. While for and while loops offer simplicity, recursion captivates with its concise representation. Each method brings its unique strengths, underscoring the beauty of choice in solving mathematical problems in the realm of programming.

Ready to see your code come to life? Give it a go on the Newtum Online Compiler! Just click, and start exploring the endless possibilities of coding. Learn, experiment, and execute your code effortlessly with Newtum – the perfect platform for coding enthusiasts!