SHARE
TWEET

addmult

phillip1882 Jan 26th, 2012 65 Never
  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
RAW Paste Data
Top