Advertisement
phillip1882

addmult

Jan 26th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. def add(x,y):
  2.    while y>0:
  3.       x,y = x^y,(x&y)<<1
  4.    return x
  5. def mult(x,y):
  6.    total = 0
  7.    while y>0:
  8.       if y&1 == 1:
  9.          total = add(total,x)
  10.       x = x<<1
  11.       y = y>>1
  12.    return total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement