0
Write a function using recursion to output all the multipliers of the passed number in ascending order.
function multiplier(num, divisor) { if (num % divisor == 0) { num /= divisor; return divisor; } else { return multiplier(num, divisor + 1) } } console.log(multiplier(18, 2))
3 Réponses
+ 2
function multiplier(num, divisor) {
if (num == divisor ) {
console.log(divisor)
} else if(num < divisor){
return;
}
else{
if(num % divisor == 0){
num /= divisor
console.log(divisor)
multiplier(num,divisor)
}else{
multiplier(num, divisor+=1)
}
}
}
multiplier(18,2) // 2,3,3
+1 follow :)
0
For example: number 18-multipliers 2 * 3 * 3. Help me to correct my code
0
Yo