Skip to content

Commit 7de0a50

Browse files
authored
Update README.md
1 parent a1fc72b commit 7de0a50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ JavaScript implementation:
6464
* @return number
6565
*/
6666
function getFibonacciNumberRecursive(N) {
67-
if (N <= 1) {
68-
return N;
67+
if (N <= 2) {
68+
return N < 1 ? 0 : 1;
6969
}
7070
return getFibonacciNumberRecursive(N - 1) + getFibonacciNumberRecursive(N - 2);
7171
}
@@ -184,8 +184,8 @@ const memo = {};
184184
* @return number
185185
*/
186186
function getFibonacciNumberRecursive(N) {
187-
if (N <= 1) {
188-
return N;
187+
if (N <= 2) {
188+
return N < 1 ? 0 : 1;
189189
}
190190
if (!memo[N]) {
191191
memo[N] = getFibonacciNumberRecursive(N - 1) + getFibonacciNumberRecursive(N - 2);

0 commit comments

Comments
 (0)