Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
void fibonac(int );
clrscr();
printf("enter the length for the series");
scanf("%d",&n);
printf("Fibonacci sequence upto %d terms is:\n\n",n);
fibonac(n);
getch();
}
void fibonac(int n)
{ static int f1=0,f2=1;
int temp;
if(n<2)
{ f1=0;
f2=1;
}
else
{
fibonac(n-1);
temp=f2;
f2=f1+f2;
f1=temp;
}
printf("%5d",f1);
}