Question: Write and test a function recurse that follows these rules: if x < 0 or y < 0: f(x,y) = x - y otherwise: f(x,y)

Write and test a function recurse that follows these rules:

  • if x < 0 or y < 0: f(x,y) = x - y

  • otherwise: f(x,y) = f(x-1,y) + f(x,y-1)

The function signature is:

def recurse(x, y): """ ------------------------------------------------------- Recursive function - example of tree recursion. Use: ans = recurse(x, y) ------------------------------------------------------- Parameters: x - an integer (int) y - an integer (int) Returns: ans - the function result (int) ------------------------------------------------------- """

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!