0 out of 464 challenges solved

Calculate Power Recursively

Write a Python function `power(a, b)` that calculates the value of `a` raised to the power of `b` using recursion. The function should handle the following cases:

1. If `b` is 0, the result is 1 (any number raised to the power of 0 is 1).
2. If `a` is 0 and `b` is greater than 0, the result is 0.
3. For all other cases, calculate the result recursively.

#### Example Usage
```python [main.nopy]
print(power(3, 4))  # Output: 81
print(power(2, 3))  # Output: 8
print(power(5, 5))  # Output: 3125
```

#### Constraints
- `a` and `b` will be non-negative integers.
- Avoid using Python's built-in `**` operator or the `math.pow` function.
def power(a, b):
    """
    Calculate the value of 'a' raised to the power of 'b' using recursion.

    Args:
    a (int): The base number.
    b (int): The exponent.

    Returns:
    int: The result of a^b.
    """
    # Base cases
    if b == 0:
        return 1
    elif a == 0:
        return 0

    # Recursive case
    # Replace the following line with the correct implementation
    pass