From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Recursive multiplication algorithm in Python

Recursive multiplication algorithm in Python - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

Recursive multiplication algorithm in Python

- [Instructor] The only way to develop proficiency and confidence with writing recursive algorithms is through practice. In this chapter, you will have the chance to do just that. For each algorithm in this section, once you understand what is required, have a good attempt on your own, and then we will provide the solution. For the first exercise, we're going to write a recursive algorithm to perform multiplication of positive integers using repeated addition. So, one way you can understand multiplication is simply by adding a number to itself over and over, and this lends itself very naturally to a recursive solution. The key to this algorithm is to understand that in multiplication, each operand has a different role. So even though 5 times 4 is the same as 4 times 5, for example, the roles of the 4 and the 5 are different in each case. Let's look at 4 times 5, for example. So by convention, the 4 is called the…

Contents