Cody Bable

Generation

generate functionTue, 25 Apr 2023

calculate the product of m x n but without using the * operator. Use both functions below def add(m, n): if m == 0: return n if n == 0: return m return add(m, succ(n)) def succ(n): return n +1

def add(m, n): if m == 0: return n else: return add(m, succ(n)) def succ(n): return n + 1 def product(m, n): if m == 0: return 0 else: return add(n, product(dec(m), n)) def dec(n): return n - 1 product(4, 5)

Questions about programming?Chat with your personal AI assistant