Skip to content

Instantly share code, notes, and snippets.

@tiger1710
Created February 19, 2019 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiger1710/dfa679f7ec3979fe2e9209f107e612cc to your computer and use it in GitHub Desktop.
Save tiger1710/dfa679f7ec3979fe2e9209f107e612cc to your computer and use it in GitHub Desktop.
#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