window.οnlοad=function()
{
//递归求和
function getsum(x){
if(x==1){return 1;}
return x+getsum(x-1);
}
//求每位数的和
function getsum(num){
if (num<10){return num;}
return num%10+getsum(parseInt(num/10));
}
//斐波那契
function getsum1(num)
{
if (num==1||num==2){return 1;}
return getsum1(num-1)+getsum1(num-2);
}
}
JS 递归
最新推荐文章于 2021-12-07 09:47:42 发布