//1-100 递归
//num1 = 1
//num2 = 2
//num3 = 3
//num3 = num2 +1
function add(num1,num2) {
let num = num1 + num2
if(num2+1<=100) {
return add(num, num2 + 1)
}else {
return num
}
}
let sum = add(1,2)
console.log(sum)
使用javascript求1-100递归
![](https://img-home.csdnimg.cn/images/20240711042549.png)