**C program for Fibonacci series** using recursion and using FOR loop : Fibonacci series is a mathematical series of **numbers** in which next number of series is derived by sum of previous two number and 0 & 1 are first two numbers of the series. So Lets see how the Fibonacci series logic works:

0,1,0+1 =1, 1+1=2, 2+1 =3, 3+2 =5, 5+3 =8, and so on..

If we wish to generalize this concept then it would be something like :

** x _{n} = x_{n-1} + x_{n-2}**

where:

**x**is term number “n”_{n}**x**is the previous term (n-1)_{n-1}**x**is the term before that (n-2)_{n-2}

Now when we write **C program for Fibonacci series** we need to keep first two numbers into consideration that is 0 and 1 (i.e. these need to hard coded in program). And then from then onwards our above generalized logic will work for us. So friends let see how to write **C program for Fibonacci series using recursion**.

### C program for Fibonacci series using recursion :

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

We can also code the same Fibonacci series logic using different method say by using the FOR loop. Let see how to write the **C program** of Fibonacci series using For loop.

### C program of Fibonacci series using For Loop or without recursion:

#include<stdio.h> main() { int n, first = 0, second = 1, next, c; printf("Enter the number of terms\n"); scanf("%d",&n); printf("First %d terms of Fibonacci series are :-\n",n); for ( c = 0 ; c < n ; c++ ) { if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } printf("%d\n",next); } return 0; }

I hope you all have enjoyed the article. If you face any issues with source code let us know in form of comments.

[…] C program for Fibonacci Series | C Code Champ […]

You’ve got great perception and I will undoubtedly be reading your other Blogs!