ELI5: Explain Like I'm 5

Tail recursion

Okay, so let's say you have to clean up your toys in your room. You have a lot of toys, and you need to put each of them in a box before you can finish cleaning your room. You start with one toy, and you put it in the box. Then you look for the next toy, and you put it in the box. You keep doing this until all your toys are in the box.

Now, let's say you have a lot of toys and a lot of boxes. You have to put each toy in a box, but you also have to remember which boxes you've already used. You start with one toy, and you put it in the box. Then you remember that you used that box. You look for the next toy, and you put it in a new box. Then you remember that you used that box too. You keep doing this until all your toys are in a box.

This second way of cleaning your room is like tail recursion. You have to remember things as you go along, so you don't forget anything. It's like a loop, but each time it loops, it remembers something new.