笔试题:递归实现斐波那契数列(1,1,2,3,5,8,13,21,34,55,89……)

function Fib(){
    var arr = [];
    function loop(index){
        if(index < 2) {
            arr[index] =1;
        }else{
            arr[index] = arr[index-1] + arr[index-2];     
        }
        if(index<1024){  //设置最大值 避免无限循环
            loop(index+1);
        }
      
    }
    loop(0);
    return arr;
}
原文地址:https://www.cnblogs.com/xunhuang/p/10442023.html