Problem 12

Multiply Recursion Challenge

Given two integers, return their product without using the multiplication (*), division (/), or modulo (%) operators, or Math methods.

Function Signature

multiply(x, y)

Parameters

  • x — an integer.
  • y — an integer.

Output

Return a number representing the product of x and y.

Constraints

  • The function must use recursion.
  • Do not use *, /, %, or Math.
  • The function should accept exactly two arguments.

Examples

multiply(6, 4)    → 24
multiply(1, 2)    → 2
multiply(0, 32)   → 0
multiply(-2, -2)  → 4
multiply(-79, 82) → -6478
multiply(79, -82) → -6478