Following is one simple solution. I just ran the same soultions and found surprising run times. have a look into the SS.
P.S. : please solve for the time complexity. 
int numberOfSteps(int num) {
int count = 0;
while(num){
count += 1;
if(num&1) num -= 1;
else num /=2;
}
return count;
}