Envisioning a Computationally Enhanced Mathematics Curriculum in Hong Kong’s Primary & Secondary Schools
Number Machine
Lesson Overview
The goal of this lesson is to enhance students’ number sense and help students explore the concept of functions and algorithms through an interactive “Number Machine” activity. This program acts as a number machine or function machine, transforming an input number into an output number using a hidden algorithm. Students will first interact with a pre-built number machine to observe how different inputs yield corresponding outputs, aiming to deduce the underlying algorithm and mathematical patterns behind different types of number machines. Subsequently, they will implement their own number machine in Scratch. Through this activity, students will strengthen their understanding of mathematical functions, patterns, and computational thinking concepts such as variables, loops, and algorithms.​
Prior Knowledge
-
Mathematics: Simple arithmetic operations (e.g., addition, subtraction, multiplication, division).
-
Computational Thinking Skills: Knowledge of variables, loops, and conditional statements in programming.
Learning Objectives
-
Understand Mathematical Functions and Patterns: Identify patterns and relationships between input and output numbers and comprehend how inputs are transformed into outputs within mathematical functions.
-
Develop and Implement Algorithms in Scratch: Design step-by-step algorithms that define the transformation process in a number machine and implement these algorithms using Scratch, effectively utilizing variables, loops, and conditional statements.
-
Problem Decomposition and Sequential Problem-Solving: Break down complex problems into smaller, manageable parts and organize the sequence of steps necessary to solve a given problem systematically.
-
Enhance Debugging and Refinement Skills: Improve problem-solving abilities by debugging and refining the number machine program, including the capacity to discern and articulate differences between expected and actual outputs.
Mathematics & CT Outcomes
-
Mathematics: Apply arithmetic operations within algorithmic processes; Experience functions and their representations.
-
CT skills: Algorithm design and implementation; Effective use of variables to manage data; Application of loops and conditionals to control program flow; Debugging skills to identify and resolve errors in the program.
Lesson Details
Begin by interacting with the number machine to observe the relationships between various input and output numbers. Challenge yourself with the machine’s prompt: “Guess what number you will get if you input 12 into the machine”. Conclude by designing your own number machine using Scratch.
Guiding Questions
-
How many input attempts did the number machine allow before posing the final question?
-
What is the number machine’s response to a correct answer? What about an incorrect one?
-
Which Scratch command enables user input interaction with the machine?
-
Which Scratch command allows the number machine’s responses to vary based on user input?
Students’ Work
In this activity, students are tasked with creating a “Number Machine” program in Scratch, building upon their observations and reasoning from the provided examples. The process involves several key steps:
​
-
Player-Computer Interaction:
-
Utilize the "ask... and wait" block to prompt the player for input, storing responses in the “answer” variable.
-
-
Algorithm Implementation:
-
Apply arithmetic operations and Scratch’s operator blocks to process the input and generate the corresponding output.
-
Repeat this process three times to reinforce understanding.
-
-
Final Quiz:
-
Use the “ask... and wait” block to pose a concluding question, evaluating the player’s comprehension.
-
Implement a mechanism to verify the player’s answer, providing feedback based on correctness.
-
In the third step, students have different ways of verifying the player’s answer, which is shown in the following student works.​
Example 1:
-
The student employs the “if... then... else...” block to assess the player’s final answer. If the answer is correct, the program acknowledges success; otherwise, it prompts the player to try again.wer” variable.

Example 2:
-
The student utilizes the “repeat... until...” block to continually prompt the player until the correct answer is provided. This approach ensures the player arrives at the correct answer through iterative attempts.

Possible Challenges and Misconceptions
Identify Patterns and Determine the Algorithm
The student may have struggled to recognize the underlying pattern or relationship between input and output numbers. This leads to designing specific solutions for individual inputs rather than a unified algorithm.

Using Conditional Statements Effectively
Students may face difficulty understanding and implementing conditional blocks such as “if...then…, else…” or “repeat…until…” to check the correctness of the player’s response. For example, failing to properly structure conditions can result in logic errors, such as skipping feedback for incorrect answers, ending the loop prematurely, or writing overlapping or contradictory conditions, which might confuse the program and lead to unintended outcomes.

Acknowledgement
The author would like to thank all the anonymous teachers and students who participated in this research.