📜  获取斐波那契数的数组 javascript 代码示例

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

代码示例3
'use strict';

let fibonacci: number[] = [0, 1];

function listFibonacci(num: number) {
  for (let i: number = 2; i < num; i++) {
    fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
  }
  return fibonacci;
}
console.log(listFibonacci(10));