📜  js 斐波那契数列 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:27.308000             🧑  作者: Mango

代码示例5
// number fibonnaci to array format
function fibonacci(nums) {
  
  let fib = [0, 1];
  let data = [];
  
  for(let i = 2; i <= nums; i++) {
    fib[i] = fib[i - 1] + fib[i - 2]; 
    data.push(fib[i]);
  }
  
  return data;
}