fork download
  1. def multiply(a, b):
  2. result = sum(b for _ in range(abs(a)))
  3. return result if a > 0 else -result
  4.  
  5. print(multiply(2, 5))
  6. print(multiply(-2, -5))
  7.  
  8. print(multiply(-2, 5))
  9. print(multiply(2, -5))
  10.  
Success #stdin #stdout 0.04s 9348KB
stdin
Standard input is empty
stdout
10
10
-10
-10