Advertisement
Josif_tepe

Untitled

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