Recursion is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem. In mathematics and computer science, a recursive function is one that calls itself within its own definition. Every recursive function must have a base case (to stop the recursion) and a recursive step.