Week 9: Recursion and Digit Logic
214 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Week 9: Recursion and Digit Logic > **Course:** Jan 2026 - Python > **Focus:** Shrinking problems by one step until the base case finishes the job. --- ## 1.

Visual strip
Relevant recall pieces for this note
Week 9: Recursion and Digit Logic
Course: Jan 2026 - Python Focus: Shrinking problems by one step until the base case finishes the job.
1. Core idea
Week 9 is recursive thinking: solve the small version, then rebuild the answer.
What to remember
- A base case stops recursion.
- A recursive call must move closer to the base case.
- Digit-count functions usually peel off the last digit with
// 10. - Digit-sum functions usually add
n % 10. - Binary conversion often strips one digit from the right and combines it back.
2. Common traps
- Missing base case.
- Recursing without shrinking the input.
- Confusing first-element recursion with last-element recursion.
- Forgetting order matters in equality.
3. Speedrun pattern
When you see a Week 9 question, ask:
- What is the simplest case?
- How does the problem get smaller?
- What arithmetic rebuilds the answer after the recursive call?
4. Micro revision
n // 10removes the last digitn % 10gets the last digitP[1:]andP[:-1]are the two common recursive list cuts
Assignment anchor
Navigation
- Previous: Week 8 Notes
- Next: Week 10 Notes