Function to find the mask for finding rightmost set bit in K
def findMask ( K ) : NEW_LINE INDENT mask = 1 ; NEW_LINE while ( ( K & mask ) == 0 ) : NEW_LINE INDENT mask = mask << 1 ; NEW_LINE DEDENT return mask ; NEW_LINE DEDENT