1342-number-of-steps-to-reduce-a-number-to-zero

DevGod
Vtuber
class Solution { public int numberOfSteps(int num) { int COUNTER = 0; while(num>0){ if(num%2==0){ num = num/2;} else{num = num-1;} COUNTER++; } return COUNTER; }}
/** * @param {number} num * @return {number} */var numberOfSteps = function(num) { let step = 0; while(num > 0){ if(num%2 === 1){ num+=-1; }else{ num = num/2; } step++; } return step;};