Recursion

Recursion is when a function calls itself to solve a problem by breaking it into smaller sub-problems. It needs a base case to stop.

General Programming

Examples

Python

def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

print(factorial(5))

Output:

120

Learn it in a lesson

See also

Back to the Dictionary