📜  打字稿代码示例中的斐波那契计数器

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

代码示例2
'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));