Advertisement
pasholnahuy

фиббоначи хуяначи

May 4th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int fib(int n)
  7. {
  8.     if (n==1 || n == 2){
  9.        return 1;
  10.     }
  11.     return fib(n-1)+fib(n-2);
  12. }
  13.  
  14. int main()
  15. {
  16.     int n;
  17.     cin >> n;
  18.  
  19.     cout  <<  fib(n) <<  endl;
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement