So what did all of those items have in common? Those are examples of recursive programs, and you can find more here at this document. I know I've been holding out on you this entire time. This is a great example of different interesting things whether it's gains or particular concepts that they've put together as examples from snap. So as a teacher, you might find them interesting. They're a little probably intimidating fortunes, but they could be great sources to inspire your students or to allow you to play around with some interesting things that have already been built. What do we have here? These are some things that don't come from the Snap examples. These are called Russian nesting dolls or maybe they're available in a lot of countries, but we commonly call them Russian nesting dolls. What's important about them for this particular discussion is that there's a big Russian nesting doll, and then there's another one that fits inside it that's maybe just a little bit smaller, another one that fits inside this a little bit smaller. This relates to the concept of recursion in programming. Why is that? Well, let's look at this example from the video you watched right before this, where they were doing the drawing circle recursive. Here's the code where we're defining the block or the method called draw circle recursive, it takes one parameter size. It did some stuff pen down, did some repeating, etc. But at the bottom, see here, its size is greater than zero, it calls the exact same code that you're in the middle of defining. It says that to solve draw circle recursive for a given size, we need to do some things, and then we're actually going to have to solve the slightly smaller one, and we have to do the slightly smaller one, and the slightly smaller one, until size equals zero. So this is the relationship. We can have these nesting solutions to something. To solve the big one, we need to have all the things underneath it. So those examples I gave you. So remember this one, I think this one looks really cool. How is this recursive? Well, up here at the top, we've got the dragon curve is the name of the method and it takes some parameters. Down here at the bottom, you'll see actually in this case, there's two recursive calls that are made in order to help solve this bigger problem. The length starts off maybe at 300 and then you can see we're reducing the length, we're dividing it by the square root of two in both cases, and order was set to five, where we're reducing one from order, and the term values are also changing. What about this one? This is called Hilbert size, is the name of the method. Again, the key thing to point out here is to solve the main Hilbert method, that definition there. In this case, four different calls to Hilbert size, reducing the values in the parameters both of the level and the angle each time. So that's interesting. Those look really cool. You might have heard of recursive and other ways. Do you by any chance teach something where there's a solution involves solving a smaller version of the problem? Maybe you do, maybe you don't. But if you remember back to factorial from your Math classes, the way we solve n factorial, is we take n times n minus 1, times n minus 2, times n minus 3, all the way down to 1. So for five, to solve five factorial, we take five and we multiply it by four factorial, and three factorial and two factorial and one factorial. See the 5 minus 1, that's 4, 5 minus 2 that's 3. So again, the idea being that we are, think of the Russian nesting dolls again. So one of the key things that you need to know about research on how to teach recursion is it's really important to start users with lots of examples. The other thing that's really recommended, is don't start by having students write their own recursive code. This usually they've told a lot of frustration like, I just don't even know what to do or type. Start by giving students programs to modify. But before we jump into that, let's look at one simpler program. Those ones I gave you they looked really cool, but honestly, they're quite complex. So let's start with a simpler example. Here's a piece of code that I will give you that I think is one of the best things to start with when teaching kids recursion. It's got that same nesting doll structure and it's really obvious, maybe what that nesting doll structure is, but let's pull it out for you. Making that a little bigger, this is what I'm going to call the nested squares code. This top, the square on the outside, that's what we're going to start, this is going to be the very first thing I'll be drawing. This is drawing a square of 100 steps on each side. Inside that, the Russian doll investing part, is a square that has 10 steps smaller. So in this case, a square of 90 on each side and the next one is 80, and so on. We can draw the arrows in, but this smallest one I'm telling you, this is of size 10. So then you can start thinking it's like "Okay, where do we stop in factorial? We went all the way down to one, in some of the others, we saw some bases there. What have we got?" Well, here is the code for my drawing nested square. So it takes one parameter, that's the side length, and if the side length is greater than five, so that's going to be where I'll stop. Well, let's walk through it and highlight it for you. I'm going to use this part here, if the side length is greater than five, then I'm going to do what I call the draw the square portion. So I'll just tell you that I start my arrow up in the top there. So if I passed on 100 like I said I did, that's greater than five. Basically now, I'm going to repeat four times move 100 steps turning 90 degrees at each end. After that, this next set of four instructions is actually going to move my pointer, changing the exponent by five, that's going to move it further to the right and the y-coordinate by negative five, is going to move it down and that's going to identify that top-left corner of the 90 square. So the second square and now this is going to be in that top left corner and ready to start again. Then this is what we call the recursive call. So this is where I'm going to define how draw nested square works. By calling drawn nested square again, saying ''I want you to solve the same problem but for a smaller size." So I'm going to subtract 10 off there and that's why you go from 100 down to 90. So giving you some vocabulary, when we talk about recursion, to make recursive code, you're always going to have two cases. You're going to have the recursive case which is where we solve a smaller thing and you're going to have a base case which is what do you do when you get to the smallest thing that you want to have because in the Russian nesting dolls, you eventually get down to the bottom and you don't go any smaller. A lot of times with creative or drawing recursive programs, there is no base case. The base case is don't draw anything else. So that gets a little bit confusing maybe when you're starting to teach kids, but they don't really miss it until you try to take them onto some other things. So what's the summary of your brief introduction to recursion? As a teacher, you're going to want to have lots of examples for students. I would say especially in block-based languages, it's probably easiest to use graphical examples. First, they're very visual and you can let students play around with them. That's come brings up the second thing which is, don't ask students to just write programs from scratch, have them modify given programs, but compared to all those complex ones I showed you from the Snap examples, start with simpler ones. They're a little more boring for students, but if they're trying to understand how it really works, it's going to be a lot easier to see nested squares or nested triangles or even nested circles, than it is going to be on those really cool already ones.