hello I'm new learning recursive but i don't know to solve with this problem, cause this one using 2 parameters, I don't know how to return with 2 arguments.
this is the normal loop ,not a recursive yet cause i dunno how to change it to recursive:
function deret2(num,num2){
var tampung = 1;
for (var i= num; i >= 1 ; i-= num2){
tampung = tampung * i ;
}
console.log(tampung);
}
deret2(12,5); //12* 7 * 2 = 168
Edit : the recursive I made :
function deret(num,num2) {
//var tampung = 1;
if (num <= 0) { // terminal case
return 1;
} else
{ // block to execute
return num * deret(num-num2,num2);
}
};
deret(12,5);
it won't work cause number* deret(2 arguments here) ?? that's why i don't know how to make this a recursive with 2 parameters, how could u save it and multiply it against 2 arguments ?
returnstatement nor this is a recursive function.num * deret2(num-num2,num2). And don't forget your base case...tampungstuff, but it should work.