## Fibonacci numbers using recursion

You must have already come across program to print fibonacci numbers without recursion, Here is given fbonacci number series using recursion.

PROS or New concept used:

1. You DONT have to print 0 and 1 first and run the loop n-2 times.

2. Giving modularity to program since recursion uses function or method thus decreases complexity to understand by a stranger coder.

### Concept:

1. TO start with the fibonacci series we first take a=-1 and b=1

thus c= a+b = -1 +1 = 0;

1 | 1 | 2 | 3 | 5 | 8 | 13 | |

a | b | c | |||||

a | b | c | |||||

a | b | c | |||||

a | b | c |

2. Then replacing the values of a and b;

a=b and b=c; AS seen from above table.

ALSO CHECK:

#include<stdio.h> void fibonacci(int a,int b,int n) {int c; if(n!=0) // Thus loop will stop when n==0 BASE CASE { c=a+b; printf("%d ",c); fibonacci(b,c,--n); // RECURSIVE CASE } } void main() { int n; printf("\nHow many numbers do you want in fibonacci series : "); scanf("%d",&n); fibonacci(-1,1,n); }

**OUTPUT:**