*** Welcome to piglix ***

Recursion


Recursion occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics and computer science, where a function being defined is applied within its own definition. While this apparently defines an infinite number of instances (function values), it is often done in such a way that no loop or infinite chain of references can occur.

In mathematics and computer science, a class of objects or methods exhibit recursive behavior when they can be defined by two properties:

For example, the following is a recursive definition of a person's ancestors:

The Fibonacci sequence is a classic example of recursion:


...
Wikipedia

...