# Recursion

Source: https://cca.twango.dev/AP-Computer-Science/recursion

# Recursion

A method calls itself to derive a solution to a problem.

## Solving a recursive problem

1. **Find the base cases.** Think about the simplest inputs whose answers are immediately known.
2. **Take the recursive leap of faith.** Identify the recursive behavior, usually by calling the method on a smaller input. Trust the smaller subproblem's result when constructing the current result.
3. **Recombine.** Build the answer to the original problem from those results.

Each recursive call must make progress toward a base case; otherwise the recursion may never terminate normally.

Related: [[methods|Methods]] · [[number-systems|Recursive base conversions]] · [[time-complexity|Time complexity]]
