write a recursive algorithm to find the nth Fibonacci elements from the Fibonacci series
0,1,1,2,3,5,8,13....
Answers
Answered by
0
Answer:
int fibonacci ( int n ) {
if ( n == 0 ) {
return 0;
}
if ( n == 1 ) {
return 1;
}
int p = fibonacci ( n - 1 );
int q = fibonacci ( n - 2 );
return p + q ;
}
Explanation:
Remember, the solution of a recursive problem for a given input depends on the solution of same problem for a smaller input.
Similar questions