๐Ÿ“˜

Recursion

When a function solves a problem by calling itself on a smaller version.

๐Ÿ˜Š In simple words

When a function solves a problem by calling itself on a smaller version.

๐ŸŽ“ Technical definition

A technique where a function calls itself with a smaller input until it reaches a base case that is solved directly.

Pseudocode example
1FUNCTION FACT(N)2    IF N <= 1 THEN3        RETURN 14    END IF5    RETURN N * FACT(N - 1)6END FUNCTION

๐ŸŽ Real-world analogy

Russian nesting dolls: open one, find a smaller one, until the tiniest.

๐Ÿ”— Related concepts

โ† Whole glossary