1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

Merge pull request #232 from shiasn/gh-pages

fix: function Fibonacci2 bug
This commit is contained in:
Ruan YiFeng 2016-07-14 22:44:31 +08:00 committed by GitHub
commit dff4d65aba

View File

@ -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);
}