Recursive Functions

In this lesson, we meet a very special type of function called the recursive functions. Let's begin!

A number of algorithmic problems can be solved with recursion when a function calls itself by name.

What is recursion?


Recursion is a method of function calling in which a function calls itself during execution.


There are problems that are naturally recursively defined. For example, the Fibonacci sequence is defined in a recursive way. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two.

fibonacci(n) = fibonacci(n-2) + fibonacci(n-1)

Parts of recursion

...
Access this course and 1400+ top-rated courses and projects.