Unset least significant K bits of a given number | Function to return the value after unsetting K LSBs ; Create a mask ; Bitwise AND operation with the number and the mask ; Given N and K ; Function call
def clearLastBit ( N , K ) : NEW_LINE INDENT mask = ( - 1 << K + 1 ) NEW_LINE N = N & mask NEW_LINE return N NEW_LINE DEDENT N = 730 NEW_LINE K = 3 NEW_LINE print ( clearLastBit ( N , K ) ) NEW_LINE