Envisioning a Computationally Enhanced Mathematics Curriculum in Hong Kong’s Primary & Secondary Schools
Euclidean Algorithm
Lesson Overview
â€‹In this task, students need to supplement the code to implement the function to calculate the HCF of two integers. The blank part examines students’ understanding of Euclidean Algorithm, which requires students to know how to use it to write code to calculate the HCF and to be able to correctly apply CT concepts such as variables, iteration, conditionals and operator.
Prior Knowledge

Mathematics: Division, Remainder, HCF (Highest Common Factor), Factor
Lesson Objectives

To employ Euclidean Algorithm to create a program that can calculate the HCF of two numbers.

To master how to use my blocks to set up subroutines.

To handle the relationship between conditional block and iteration block [repeat until XX].

To know how to set variables related to remainder and quotient and how to swap the value of two variables.

To grasp how to set the list in Scratch.
Mathematics & CT Outcomes

Mathematics: Euclidean algorithm, mod

CT Skills: variable, iteration, conditionals, sequences, operator, subroutines; algorithmic thinking, automation, reusing and remixing
Teaching Resources
The Desmos Activity used in this Task.
Lesson Details
We can easily calculate the HCF (highest common factor) of 21 and 14 is 7, and the HCF of 121 and 99 is 11. But what is the HCF of 123456789 and 987654321? It’s actually 9! How can we calculate this quickly? Let’s do it by Scratch!
Complete the remaining part of the code!
Student's Work
About these samples:
The most important aspect of this activity is to find the HCF of two numbers using the Euclidean Algorithm. Among the points worth noting in these two works are:

The way to set reminder: set reminder to b mod a.

Two ways to set quotient: (1) set quotient to floor of b/a; (2) set quotient to (b – remainder) /a.

Two ways to swap the value of two variables:
Possible Challenges and Misconceptions
Sample 1: Incorrect My Blocks definition for exchanging of two numerical values
In this work, an error occurs in the My Blocks where the values of two numbers are exchanged. This swap block does not exchange the values of a and b, and thus will cause an error when a > b. In addition, in the repeat until block, this student used a new method to convert the values of two numbers: a and reminder [set b to a; set a to reminder]. This method of swapping values is correct, but the student forgot to delete the swap block that follows, which also causes an error in the code.
Sample 2: Misconceptions about the method of exchanging values of two numbers in different blocks
The methods of swapping two numeric values can be divided into two categories: either by using the variable block directly (Figure 8b), or by defining a new block by setting My block (Figure bcd), which is convenient for repeated calls. It is worth noting that these two methods are not the same. When using the variable block directly, if [set a to b] or [set b to a] directly, the values of both a and b will change immediately and the value cannot be swapped (Figure 8a). Therefore, the third variable [set temp to A] must be added as the intermediate variable to store the value (Figure 8b). In My block, however, both methods can swap values (Figure 8cd).
Acknowledgement
The author would like to thank Alvin Chan for designing this lesson and appreciate all the anonymous teachers and students who participated in this research.