Question: Stuck here in python recursion question, please help. When we multiply x * y, where x > 0 and y > 0, we are simply
Stuck here in python recursion question, please help.
When we multiply x * y, where x > 0 and y > 0, we are simply adding x a total of y times. We can define x * y recursively as follows:
x * y = x, if y = 1
x * y = x + x*(y-1), if y > 1
Complete the following Python program to compute num1 * num2 recursively:
def main():
# Local variables
num1 = 0
num2 = 0
# Get the first positive nonzero integer from
# user.
while num1
num1 = ________________________________________
# Get the second positive nonzero integer from # user.
while num2
num2 = ________________________________________
# Call the multiply function to compute num1 * num2 recursively,
# and display the product.
______________________________________________________
def multiply(num_1,num_2):
# You complete this function recursively
main()

[1] When we multiply x * y, where x > 0 and y > 0, we are simply adding x a total of y times. We can define x * y recursively as follows:* x*y-x+x*(y-I), if y 14 Complete the following Python program to compute num1 * num2 recursively: def main():d # Local variables- num1 = 04 num2 -0 # Get the first positive nonzero integer from- # user. whie num1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
