Write a program to generate Fibonacci series with the help of recursion.

#include
#include
int recfib(int n)
{
if(n==1)
{
return 0;
}
else if(n<3)
{
return 1;
}
else
{
return(recfib(n-1)+recfib(n-2));
}
}
void main()
{
clrscr();
int n;
cout<<"n Fibonacci series generation using recursion";
cout<>n;
for(int i=1;i<=n;i++)
{
cout<<recfib(i)<<" ";
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *