# The idea behind recursion

In computer science, a methods or function exhibits recursive behaviour when they can be defined by two properties: (1) a simple *base case* with a terminating scenario that does not use recursion to produce an answer. (2) A set of rules that reduce all other cases toward the base case (*recursion*).

For example, the following is a recursive definition of a person's ancestors:\
\&#xNAN;*Base case:* one's parents are one's ancestors.\
\&#xNAN;*Recursion step:* the ancestors of one's ancestors are also one's ancestors.

Another example is a recursive definition of natural numbers:\
\&#xNAN;*Base case:* `0` is a natural number.\
\&#xNAN;*Recursion step:* if `n` is a natural number, then `n + 1` is a natural number.

![Another example is visual recursion, also so-called the Droste-effect. Here an image contains a smaller version of itself.](https://3022306672-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LBv1tBXapkvuxnL2KnQ%2F-LC-JdEbFjENpbaE_zlU%2F-LC-KDSPLSby8uszJXkF%2FDroste_cacao_100gr_blikje%2C_foto_02.jpg?alt=media\&token=3dd41740-a155-459a-a2c9-f68b1ae37720)

The exercises on the following pages are examples of cases in which a recursive approach simplifies solving a computational task.
