Project: Multiply with recursion

Write a recursive function named multiply that takes two positive integers and returns their product. It cannot use the * operator. It has to find the answer by adding. This shows the idea:

7 * 4 = 7 + (7 * 3)
7 * 3 = 7 + (7 * 2)
7 * 2 = 7 + (7 * 1)
7 * 1 = 7
So, 7 * 4 = 7 + (7 + (7 + (7)))

Your function cannot use a loop.

Save the file as multiply_recur.py.

Show a solution

Try the project on your own first. This is one working solution, followed by its tests. Press Run to run the tests. Read them to see what thorough testing looks like, then change the solution and run again to watch a test fail.

Projects run on your own computer, so you tell us when you are done.