AntonS2000

den_1

Dec 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<map>
  4. #include<string>
  5.  
  6. using namespace std;
  7.  
  8. int  fib(int n){
  9.   if(n == 0){
  10.       return 0;
  11.   }
  12.   if(n == 1){
  13.     return 1;
  14.   }
  15.   return fib(n-2) + fib(n-1);
  16. }
  17.  
  18. int main() {
  19.  
  20.     cout << "enter n" << endl;
  21.     int n;
  22.     cin >> n;
  23.    
  24.     int i;
  25.     for(i = 0; fib(i) <= n; i++);
  26.    
  27.     cout << fib(i) << endl;
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment