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))

6th May 2021, 5:58 AM
Тимур Завьялов
Тимур Завьялов - avatar
3 Antworten
+ 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 :)
6th May 2021, 11:52 AM
VuxxLong
VuxxLong - avatar
0
For example: number 18-multipliers 2 * 3 * 3. Help me to correct my code
6th May 2021, 5:59 AM
Тимур Завьялов
Тимур Завьялов - avatar
0
Yo
6th May 2021, 2:56 PM
Rohit Danu
Rohit Danu - avatar