Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Time complexity of Recursively Finding Nth Fibonacci Number.
int Fibonacci(int n) { // T(n)
if (n <= 1) { // 1
return n; // 1
}
int prev = Fibonacci(n-1); // T(n-1)
int prevprev = Fibonacci(n-2); // T(n-2)
return prev + prevprev; // 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment