Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 258 Bytes

Number of Steps to Reduce_a_Number_to_Zero.md

File metadata and controls

17 lines (14 loc) · 258 Bytes

class Solution { public:

int numberOfSteps(int num) {
    int count = 0  ;
    while(num!=0){
    if ( num %2==0)
    num = num/2;
    else
    num = num-1;
    count++;
    }
    
    return count;
}

};