Recursion: If Divider Doesn’t Divide The Number –> Divider goes up by one untill divider === number

  javascript
The number equals 100 ("this is not the code. I am illustrating the problem")
script : (
   number: divider,
   100/2 = 50 --> It can be divided by 2 again and still more than 0,
   50/2 = 25 --> It can be divided by 2 again and still more than 0,
   -->25/2 = It cannot be divided by 2 anymore(12.5)but it's still more than 0, so the divider goes up by one,

   25/3 = but it's still more than 0, so the divider goes up by one,
   25/4 = but it's still more than 0, so the divider goes up by one,
   25/5 = 25/5 can be divided,
   5 "===" 5 condition met
) 

I currently stuck on –> step please help any other suggestion is greatly appreciated.
Reason: just trying to automate a math problem for my homework
Math problem: count how many times can the number be divided by 2, 3, 5…

var number = 100;


function howMuch(n, divider = 2){
  if( Math.floor(n) !== n){
    console.log(n)
    if(n > 0){ //maybe here the condition is not right?
      return howMuch( divider++)
    } else return;
  } else {
            console.log(n)

    return howMuch(n / divider)
  }
}

console.log(howMuch(number))

Source: Ask Javascript Questions

LEAVE A COMMENT