Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find N-th Fibonacci number using recursion.
int fibonacci(int n) {
if (n == 1) {
return 0;
}
if (n == 2) {
return 1;
}
int n_minus_1_fibonacci = fibonacci(n-1);
int n_minus_2_fibonacci = fibonacci(n-2);
return n_minus_1_fibonacci + n_minus_2_fibonacci;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.