Advertisement
chevengur

СПРИНТ № 5 | Итераторы | Урок 7: Стандартные алгоритмы — рекурсия 1/3

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