mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
fix: function Fibonacci2 bug
This commit is contained in:
parent
baabc6fc2c
commit
a33b928158
@ -1216,7 +1216,7 @@ factorial(5, 1) // 120
|
||||
```javascript
|
||||
function Fibonacci (n) {
|
||||
if ( n <= 1 ) {return 1};
|
||||
|
||||
|
||||
return Fibonacci(n - 1) + Fibonacci(n - 2);
|
||||
}
|
||||
|
||||
@ -1230,8 +1230,8 @@ Fibonacci(10); // 89
|
||||
|
||||
```javascript
|
||||
function Fibonacci2 (n , ac1 = 1 , ac2 = 1) {
|
||||
if( n <= 1 ) {return ac1};
|
||||
|
||||
if( n <= 1 ) {return ac2};
|
||||
|
||||
return Fibonacci2 (n-1 , ac2 , ac1 + ac2);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user