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.