Question #257

What is the output of the code snippet below?
def test(i,j):
    if(i==0):
        return j
    else:
        return test(i-1,i+j)
print(test(4,7))

The function will continue to call itself until i becomes 0. i and j will respectively become 4 and 7, 3 and 11, 2 and 14, 1 and 16. Eventually, 17 is returned. (programiz.com/python-programming/recursion)


Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵