Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<map>
- #include<string>
- using namespace std;
- int fib(int n){
- if(n == 0){
- return 0;
- }
- if(n == 1){
- return 1;
- }
- return fib(n-2) + fib(n-1);
- }
- int main() {
- cout << "enter n" << endl;
- int n;
- cin >> n;
- int i;
- for(i = 0; fib(i) <= n; i++);
- cout << fib(i) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment