Fast Enterprises Interview Question

Write a function that multiplies 2 integers without using the multiply operator.

Interview Answer

Anonymous

May 13, 2023

def multiply(a, b): result = 0 for i in range(abs(b)): result += abs(a) if a < 0 and b < 0: return result elif a < 0 or b < 0: return -result else: return result