IT lexicon Programming Recursion

Recursion

Programming På svenska → Updated: 2026-05-23

A function that calls itself to solve a problem.

Classic example: factorial. fact(n) = n * fact(n-1), with base case fact(0) = 1. The function calls itself until it hits the base case, then everything unwinds.

Natural for tree structures (file system, DOM, syntax trees) and divide-and-conquer algorithms (quicksort, merge sort). Risk: stack overflow if the recursion goes too deep.

← Back to the lexicon