The recursive function (from lat. Recursio - return) is a numerical function a numerical argument, which in its record contains itself. This record allows you to calculate the values based on values , similar to reasoning by induction . To make the calculation complete for any , it is necessary that for some the function was defined non-recursively (e.g. for )
Examples
An example of a recursive function giving the nth Fibonacci number :
Guided by this record, we can calculate for any positive integer n in finitely many steps. True, along the way you have to additionally calculate the values
.
Closed form
In connection with overhead, it is useful to know if a recursive function has a non-recursive (closed) form.
The closed form may not be found for all recursive functions (relations). For some of them, only approximate closed forms were found. Some recursive relationships, such as factorial , are considered elementary mathematical operations.
For example, a recursive function that describes the sum of numbers in a natural series:
can be translated into closed form: .
Applications
Recursive functions play an important role in the theory of algorithms , since many algorithms have a recursive structure.