Count the function calls

Report a typo

Below you can see a slightly different version of a function from the theory that recursively raises a number to its positive power. For example, finds the value of 585^8.

def pow_rec(number, power):
    # base case
    if power == 0:
        return 1
     # base case
    elif power == 1:
        return number
     # recursive case
    else:
        return number * pow_rec(number, power - 1)

How many times will the function be called when the original call is:

pow_rec(3, 5)
Enter a number
___

Create a free account to access the full topic