递归的前提:
/** * 1 1 2 3 5 8 13.... * 求第N位上的数 */
function f(n) { if (n == 1 || n == 2) { return 1; } return n = f(n - 1) + f(n - 2) } console.log(f(7));
js 用函数重写斐波那契数列
原文:https://blog.51cto.com/wangzhiyuan/2474203