Introduction to Recursion
Explore the concept of recursion in Python. Understand how recursive functions work with base and recursive cases, and learn when to use recursion to solve problems by breaking them into subproblems or handling unknown loops. This lesson helps you grasp recursive problem solving with practical examples.
We'll cover the following...
We'll cover the following...
Repetitions
There are two ways to repeat a set of statements in a function:
- By using a
whileorforloop. - By calling the function from within itself.
The first method is known as iteration, and the second is known as recursion.
The functions that use iteration are called iterative functions, and those that use recursion are called recursive functions.
Recursive function
A Python function can be called from within its ...