Recursion function question again

42 Views Asked by At

http://vvcap.net/db/3RxO1KX2d4LxgD714Tyh.htp

mult(x,y)= mult(x-1,y)+4 mult(0,4)=0

mult(1,4)=mult(0,4)+4 mult(2,4)=mult(1,4)+4 mult(3,4)=mult(2,4)+4

I'm not sure whether this is correct, but i think it does calculate the four time tables ? since it's just adding four to the previous one

2

There are 2 best solutions below

2
On

I will show a method using Python code. This works for integer $m, n \ge 0$.

 def mult(m, n):
        if(n == 0):
             return 0
        return mult(m, n - 1) + m
0
On

This is an interesting problem, because it requires 2 inputs. I believe the following function work for any m, or n.

mult(m,n = 0), mult(m,n) = mult(m,n-1) + m