In words
What it is, why it matters, and what it is like.
Why am I learning this?
This is the mental skill that lets you handle tasks which seem too big or tangled to solve all at once, by breaking them into smaller, identical copies of themselves. You likely encounter this pattern in everyday life without realizing it: when a file explorer shows folders inside other folders, allowing you to drill down until you find a specific document; or when a customer service agent delegates a complex complaint to a specialist who handles only the remaining details. Once you can think this way, you gain the ability to write instructions that repeat naturally without getting stuck in endless loops that skip items or process them twice. You will also be able to predict why certain automated systems stay stable even when processing long, complicated inputs — they handle each small piece using the exact same reliable rule used for any single piece. This page builds that core habit; later, you will see how to define the stopping point clearly and how this pattern solves classic logic puzzles.
The idea, in plain terms
You already know how to solve a big task by taking one small action and then doing it again. Recursion is the same idea, but with a crucial twist: instead of repeating the action on the *same* problem, you repeat it on a *smaller* version of the problem. You keep making the problem smaller until it becomes so simple that you can solve it instantly without any further work. The trick lies in how you define the task: you must be able to describe 'how to solve this problem' as 'first, do the same thing to make the problem slightly smaller, then add what you get back.' This sounds like a circle, and it is, but the circle has an exit door: a 'base case' — a version of the problem so small that no further shrinking is needed. For example, imagine counting down from five to one. The rule is 'say the current number, then count down from the next lower number.' But you must also have a rule for when you reach zero: 'stop.' Without that stopping point, you would count forever into negative numbers. The hard part is not writing the steps down — it is *seeing* that any complicated problem can be split this way. Once you see it, the solution follows. First, name the situation where you stop (the base case). Second, name what makes the problem smaller (the shrinking argument). Then, trust that the smaller version will handle itself.
An analogy
Think of standing between two parallel mirrors in a shop window. You look into the first mirror and see your reflection. Inside that reflection is a second mirror showing another reflection, which shows another, and so on, stretching back infinitely. To get to the 'deepest' part of this chain, you must accept that each image contains a smaller version of the whole scene — including the mirrors themselves. The action 'look at the next reflection' is repeated indefinitely. However, in reality, the light fades, or eventually, you look at a specific small object (your base case) to stop the mental exercise of tracing the infinite regress. This analogy captures the self-similar nature of recursion: each part looks like the whole. But here is where the analogy breaks: mirrors show images passively; recursion requires an active rule that shrinks the problem, and unlike physical reflections, recursive steps often branch out into multiple smaller tasks rather than just one.
Definition
Recursive thinking is the practice of solving a problem by reducing it to a simpler version of itself, repeating this reduction until you reach a trivial case that can be solved directly, then combining the results to solve the original.
Where this sits
You have used this pattern implicitly in arithmetic: to add a list of numbers, you add the first number to the sum of the remaining numbers. This page introduces the explicit habit; the library's topic on Base Cases and Recurrence teaches you how to write that rule down precisely — the 'recurrence relation' is simply the formula that links a step to the one before it. A later section on Stack Memory Behaviour explains the physical cost of this method — each time you 'shrink' the problem, your brain (or computer) must remember where it left off, which uses up space and can be exhausted if the chain is too long.