Created
February 19, 2019 11:55
-
-
Save tiger1710/dfa679f7ec3979fe2e9209f107e612cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int f(int n, int prev = 0, int next = 1) { | |
if (not n) return prev; | |
return f(n - 1, next, prev + next); | |
} | |
int main(void) { | |
cout << f(4) << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment