This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

addmult

By: phillip1882 on Jan 26th, 2012  |  syntax: Python  |  size: 0.21 KB  |  views: 63  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data