Recursion is a fundamental programming technique where a function calls itself to solve a problem. It consists of two key components: a base case that serves as the stopping condition, and a recursive step where the function calls itself with a smaller version of the original problem.
Let's look at a classic example: calculating factorial. The factorial of n is n times the factorial of n minus 1. Our base case is zero factorial equals 1. The recursive step multiplies n by the factorial of n minus 1. This creates a chain of function calls that eventually reaches the base case and returns the result.