146. C Program to Print Fibonacci Series using Recursion.
How does this program work?
- In this C programme you will learn about how to print fibnocci series using recusrion method.
- Here recursion method is used to get the output.
Here is the code
#include <stdio.h>
int Fibonacci(int);
int main()
{
int a, i =0, b;
scanf("%d",&a);
printf("Fibonacci series\n");
for (b=1;b<=a;b++ )
{
printf("%d\n", Fibonacci(i));//To display the outputs
i++;
}
return 0;
}
int Fibonacci(int a)
{
if ( a == 0 )
return 0;
else if ( a== 1 )
return 1;
else
return ( Fibonacci(a-1) + Fibonacci(a-2) );//To compute fibonacci series
}