Write a program to find the nth term in the Fibonacci series using recursion.
Answers
Answered by
0
Answer:
#include<iostream>
using namespace std;
int fib(int n)
{
if((n==1)||(n==0))
{
return(n);
}
else
{
return(fib(n-1)+fib(n-2));
}
}
int main()
{
int n,i=0;
cout<<"number of terms are:";
cin>>n;
cout<<"\nFibonacci Series\n";
while(i<n)
{
cout<<" "<<fib(i);
i++;
}
return 0;
}
Similar questions