To this point, our primary tools for implementing repetition have been loops -- both while and for. However, we can also use an idea called *recursion* to implement computations with repeated structure. Writing recursive code requires that you look at structures from a different perspective. Let's look at an example. This line of code prints an entire string, followed by a newline. When we write this code, we're thinking of s as a string. This code does the same thing, but it prints every character separately, using a loop. When we write this code, we're thinking of s as a sequence of characters. This is an example of *iterative thinking*: s is a *sequence* of characters. Loops work well on sequences. So what code would we write if we thought of s as a single character followed by a string? At first glance, this code may be quite unsettling. After all, it is defining a function called print_recursive that uses itself in its own definition. Let's break this function down, so we understand how it works. Recursive functions work by solving one small piece of the problem at a time. In our example, the problem is to print each character in a string, and we are given the string to print as an argument. However, since we're thinking recursively, let's think of the argument s as a pointer to the first character of the string. Our function solves one piece of the problem by printing that first character. And then -- and here's the recursive part -- calling itself to handle the rest of the problem. Why does this work? Let's start with a base case. The simplest string is the empty string. In this case, there's nothing to print, so we print the end of line character and we're done. So here's a slightly harder case. It's a string with a single character. In this case, we print a single character -- r. And then call the function on an empty string. We've already solved that problem, so we're done. Do you see the pattern? Let's do one more. Now we'll print a string with two characters. We'll print a single character -- r. And then call the function on the string 'o', of length 1. And we know we can do that, so we're done. So our recursive solution works by viewing a string as a single character, which it handles, followed by a string, which it handles by calling itself. In each step, the problem -- the string to print -- gets smaller. Eventually, the problem is just the character '\0', and we're done. So, is our recursive solution better than the iterative or full-string solutions? Probably not. It's certainly a longer solution, and it's hard to be simpler than just using the %s format in a printf. However, we arrived at our recursive solution by thinking about strings in a different way -- a *recursive* way. While this problem wasn't any easier to solve this way, there are problems that *are* easier when viewed recursively. In the next video, we'll look at another example that uses a recursive view of a string, and then we'll take a look at a problem that is much easier to solve recursively than it is to solve iteratively.