利用递归思路,让javaScript函数调用自身实现阶乘,思路应该是num*factorial(num-1)
function factorial(num){
if(num<0){
return -1
}
if(num == 0){
return 1
}
return num*factorial(num-1)
}
利用递归思路,让javaScript函数调用自身实现阶乘,思路应该是num*factorial(num-1)
function factorial(num){
if(num<0){
return -1
}
if(num == 0){
return 1
}
return num*factorial(num-1)
}