Fast seeking multiply, greatest common divisor
1, seeking fast ride
def egypt(x,y):
sum = 0
while x != 0:
if x % 2 == 1
sum = sum + y
x = x //2
y = y *2
return sum
2, quickly find the greatest common divisor
def gcd(x,y):
while (x != 0) and (y !=0):
if x > y:
x = x -y
else:
y = y -x
if x == 0:
return y
else :
return x