Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int fib(int x) {
- if (x == 1 || x == 0) {
- return 1;
- }
- return fib(x-1)+fib(x-2);
- }
- int main() {
- int num;
- while(cin >> num){
- cout << fib(num) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement