Exam-style question
Try this first
Which function has a general case that moves its argument towards the base case?.
- A.```python def count(n): if n == 0: return count(n - 1) ```
- B.```python def count(n): if n == 0: return count(n + 1) ```
- C.```python def count(n): return count(n) ```
- D.```python def count(n): if n == 0: return count(10) ```
Answer and explanation
Concise answer
```python def count(n): if n == 0: return count(n - 1) ```
Why this is correct
The function stops when n is 0 and decreases n on each general-case call, so the calls move towards the base case.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
