Skip to content

Instantly share code, notes, and snippets.

@melwinalm
Created February 28, 2018 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melwinalm/4f5d19873679c5df13846e2aad4e041d to your computer and use it in GitHub Desktop.
Save melwinalm/4f5d19873679c5df13846e2aad4e041d to your computer and use it in GitHub Desktop.
def multiply(a,b):
if a > b:
left = a
right = b
else:
left = b
right = a
prod = 0
while left > 0: # Loop till you reach 1
if left%2 != 0: # Add the value to product variable if the left column value is odd
prod = prod + right
left = left >> 1 # Right shift
right = right << 1 # Left Shift
return prod
print(multiply(127,68))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment