programming-examples/python/Math/Multiply two integers without using the star operator in python.py
2019-11-15 12:59:38 +01:00

11 lines
237 B
Python

def multiply(x, y):
if y < 0:
return -multiply(x, -y)
elif y == 0:
return 0
elif y == 1:
return x
else:
return x + multiply(x, y - 1)
print(multiply(3, 5));