Question: PROVE BY INDUCTION that the below algorithm is correct: (The code is in Python): The code was written from the following question: Write a Python
PROVE BY INDUCTION that the below algorithm is correct:
(The code is in Python): The code was written from the following question: Write a Python function product(a, b) that recursively computes and returns the value of a times b. Use only the addition operator, and do not use any loops. You can assume that both parameters are non-negative integers.
def mult(a, b): if a == 0: return 0 elif a == 1: return b else: return b + mult(a-1, b)
print(mult(5,4))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
