📜  斐波那契递归方法 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:02.297000             🧑  作者: Mango

代码示例1
let fibonacci = function(result, len) {
  // result[0, 1]; considering result as an array
  if(result.length >= len) {return result;} // exit recursion when limit reached.
  result.push(result[result.length-2] + result[result.length-1]);
  return fibonacci(result, len);  //return function until limit is reach.
}