Recursion

Recursion is a process in computer programming in which a function calls on itself as a subroutine. The concept is helpful when addressing a problem that can be solved by breaking it up into smaller copies of the same problem. Every time a recursive function runs, it tells itself to run again, not stopping until it meets a specified condition. Functions that incorporate recursion are called recursive functions.

A software developer building a recursive function needs to identify the base case. The base case is the part of the problem where the solution is known, so the problem is solved without more recursion. A recursive function iterates until it reaches the base case. At that point the recursion ends, and the program can move on to the next task.

Properly-used recursion is an efficient programming method since it minimizes the amount of code needed to complete a task. However, if the base case is not set (or is not reachable), the recursion will continue indefinitely. Endless recursion is called an infinite loop and will eventually cause a program to crash.

Updated October 31, 2022

Definitions by TechTerms.com

The definition of Recursion on this page is an original TechTerms.com definition. If you would like to reference this page or cite this definition, you can use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about the Recursion definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.