function fib(max) { let t, a = 0, b = 1, arr = [a, b]; while (arr.length < max) { [a, b] = [b, a + b]; arr.push(b); } return arr;}fib(5);结果:[0, 1, 1, 2, 3]
本文共 252 字,大约阅读时间需要 1 分钟。
function fib(max) { let t, a = 0, b = 1, arr = [a, b]; while (arr.length < max) { [a, b] = [b, a + b]; arr.push(b); } return arr;}fib(5);结果:[0, 1, 1, 2, 3]
转载于:https://www.cnblogs.com/lqw007/p/9603157.html