The ideas underlying this problem come from number theory: Euclid's algorithm for finding highest common factors, and continued fractions for rational numbers. The problem could be used with students who are already familiar with one or both of these ideas, or with students who have not come across either (and in the latter case the problem would make a nice way to introduce the ideas, or simply an interesting context in which to develop mathematical thinking and problem-solving skills).
An attractive feature of this problem is that it can be presented with very little initial introduction. Students can be given the interactivity with which to experiment in pairs or small groups, or it could be displayed on a board to a larger group. Don't tell them what the background to the problem is!
Invite the students to study the picture for a single pair of values, and to consider what the important features are. Ask the students to think about which aspects might change.
Show the students another picture for another pair of values, and ask them to think about whether they wish to change their ideas on which features might change and which might stay the same.
This gives students the opportunity to explore the idea underlying the pictures and to consider it carefully, without the temptation to keep trying lots of pairs of values in the interactivity and just guessing.
Encourage students to draw their own examples. They could test these using the interactivity, to see whether they have got the idea. They may need a few attempts to understand the process by which the pictures are produced, since they are (deliberately) displayed in a static way but are the outcome of a process. Once they think they have understood the process, they can select the option to show the process for comparison.
Invite students to pick out interesting aspects to investigate for themselves. For example, they might choose to work out whether they can predict the size of the smallest square given the starting numbers, or to consider whether several pairs of numbers could give rise to the same picture, or to consider whether they can find the starting numbers given the picture, or to consider whether they can represent a picture by some equations that describe the process. They might pick out Fibonacci numbers as being particularly interesting, and might choose to investigate other Fibonacci-type sequences (with the same recurrence rule for finding terms, but with different starting terms).
Students may start making some conjectures, which they can be encouraged to justify. For example, can they use the diagrams to show that the side length of the smallest square is the highest common factor of the sides of the initial rectangle? If they have already come across Euclid's algorithm and/or continued fractions, they might start relating the pictures to those ideas. If they have not, they might welcome some input (late in the investigation) on how to present the concepts in a standard way (using equations for Euclid's algorithm, or as a continued fraction).
Students could be invited to think about the number of stages it takes for the process to finish (indeed, initially to show that the process does finish).
They could be invited to think about what happens if the side lengths are not integers, and so to move on to infinite continued fractions corresponding to irrational numbers.
Students might also like to think about the connection with solving Diophantine equations of the form ax + by = c.
There is nothing that students need to know in order to work on this problem, but some may need more guidance than others on good questions to investigate.
There is a relevant NRICH article on Tangles, which comes with an associated interactivity.
Euclid’s algorithm appears in many introductions to number theory, such as The Higher Arithmetic by H. Davenport (published by CUP). There are also expositions readily available on the internet. For example, there is an NRICH article by Alan and Toni Beardon, which comes with an associated Java applet illustrating Euclid’s algorithm.