Advertisement
Guest User

Untitled

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