Answer:
In Python:
def times(x,y):
if y<0:
return -1*times(x,y*-1)
if y == 1:
return x
return x + times(x,y-1)
x = int(input("x: "))
y = int(input("y: "))
print(times(x,y))
Explanation:
I answered the question using Python3
This defines the function
def times(x,y):
This checks for negative values
if y<0:
return -1*times(x,y*-1)
This is the base case where y = 1
if y == 1:
If true, the value of x is returned
return x
This returns the recursion and it is repeated until the base case is achieved
return x + times(x,y-1)
This prompts user for x value
x = int(input("x: "))
This prompts user for y value
y = int(input("y: "))
This calls the recursion and also prints the result
print(times(x,y))