mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Fix Fibonacci algorithm (#180)
This commit is contained in:
parent
ffd4798f23
commit
2c6982f154
|
@ -64,7 +64,7 @@
|
||||||
"Recursive:\n",
|
"Recursive:\n",
|
||||||
"* Fibonacci is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34...\n",
|
"* Fibonacci is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34...\n",
|
||||||
"* If n = 0 or 1, return n\n",
|
"* If n = 0 or 1, return n\n",
|
||||||
"* Else return fib(n-1) + fib(n+2)\n",
|
"* Else return fib(n-1) + fib(n-2)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Complexity:\n",
|
"Complexity:\n",
|
||||||
"* Time: O(2^n) if recursive or iterative, O(n) if dynamic\n",
|
"* Time: O(2^n) if recursive or iterative, O(n) if dynamic\n",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user