NOTE: I am not a python expert, so there could be some obvious bugs in this simple piece of code. As always use at your own risk.
print "Input the first number"
a=input()
print "Input the next number to be multiplied with %d" %a
b=input()
res=0
while a:
if a & 0x1:
res = res + b
a = a >> 1
b = b << 1
print "The result is %d\n" %res
No comments:
Post a Comment