Advertisement
Guest User

Untitled

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