0 out of 464 challenges solved
The Catalan numbers are a sequence of natural numbers that have many applications in combinatorial mathematics. The nth Catalan number can be defined recursively as:
\[
C(n) = \sum_{i=0}^{n-1} C(i) \cdot C(n-i-1), \text{ for } n > 0, \text{ and } C(0) = 1.
\]
Write a Python function `catalan_number(n)` that computes the nth Catalan number using recursion.
#### Example Usage
```python [main.nopy]
print(catalan_number(0)) # Output: 1
print(catalan_number(3)) # Output: 5
print(catalan_number(5)) # Output: 42
```
#### Constraints
- The input `n` will be a non-negative integer.
- The function should use recursion to compute the result.def catalan_number(n):
"""
Compute the nth Catalan number using recursion.
Args:
n (int): The index of the Catalan number to compute.
Returns:
int: The nth Catalan number.
"""
# Base case
if n == 0:
return 1
# Recursive case
# Placeholder for the recursive computation
pass