标签:== ons var -- parse snippet script OLE 递归
递归实现
function getSum(x) {
if (x == 1) {
return 1;
}
return x + getSum(x - 1);
}
var result = getSum(100);
console.log(result);
递归实现
function getnumberSum(x) {
if (x < 10) {
return x;
}
return parseInt(x % 10 + getnumberSum(x / 10));
}
console.log(getnumberSum(123));
JavaScript - 代码片段,Snippets,Gist
标签:== ons var -- parse snippet script OLE 递归
原文地址:https://www.cnblogs.com/allen2333/p/9221053.html