You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//leet code problem 509. fibonacci nth term using recursion
class Solution {
public:
int fib(int n) {
//base case
if(n==0)
return 0;
if(n==1)
return 1;
int ans=fib(n-1)+fib(n-2);
return ans;
}
};
/*The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,