← Back to challenges

Recursion: Multiplication by Addition

PythonHardrecursionmath

Instructions

Create a function that returns the product of two integers. This process of multiplication can be achieved via repetitive addition, thus, the process can be done recursively.

Examples

multiply(10, 2) ➞ 20

multiply(-51, -4) ➞ 204

multiply(3, 9) ➞ 27

multiply(-21, 5) ➞ -105

multiply(1024, 7) ➞ 7168

multiply(273, -6) ➞ -1638

Notes

  • You're expected to solve this challenge using a recursive approach.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.