Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int f(int n){
- if(n==0) return 0;
- if(n==1) return 1;
- return f(n-1) + f(n-2);
- }
- int fib(int n) {
- int ans = f(n);
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement