Advertisement
Guest User

Untitled

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