My favorite definition of recursion is, "A recursive function is a function that calls itself, until it doesn't." That probably doesn't make a lot of sense, so let's jump right in and program one.
Let's look at another (more practical?) example. In the next two videos we'll write code to check if a word (or phrase) is a palindrome. Before we get to the palindrome function though, we'll need to write a helper function.
Review Questions
The following are examples of questions similar to what you can expect to see on the next exam.
- What is a recursive function? A function that calls itself, until it doesn't.