Answer:
// Code in C++.
// headers
#include <bits/stdc++.h>
using namespace std;
// recursive function to find nth term of Fibonacci series
int fib(int num)
// driver function
int main()
{
// variables
int num, term;
cout << "Enter the position value : ";
// read the value of num
cin >> num;
// call the function
term = fib(num);
// print the nth term
cout <<"The "<<num<< "th Fibonacci number is: " <<term<<endl;
return 0;
}
Step-by-step explanation:
Read the value of term number from user and assign it to variable "num".Then call the recursive function fib() with parameter "num".In this function, if num=1 or num=0 (base case for recursive call) then function will return the value of num. otherwise it will recursively call itself and find the nth term of the Fibonacci series.
Output:
Enter the position value : 6
The 6th Fibonacci number is: 8