Multiplication of two numbers with shift operator | Function for multiplication ; check for set bit and left shift n , count times ; increment of place value ( count ) ; Driver code
def multiply ( n , m ) : NEW_LINE INDENT ans = 0 NEW_LINE count = 0 NEW_LINE while ( m ) : NEW_LINE INDENT if ( m % 2 == 1 ) : NEW_LINE INDENT ans += n << count NEW_LINE DEDENT count += 1 NEW_LINE m = int ( m / 2 ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 20 NEW_LINE m = 13 NEW_LINE print ( multiply ( n , m ) ) NEW_LINE DEDENT