Number: Prime factor lock
View Sequence overviewSystematic counting, pattern recognition and generalisation can be used to solve a design problem involving combinations.
Whole class
Prime factor lock Slides
Video: Catalyst: Prime number keys (2:57)
Each group
Device with access to the Prime factor lock digital interactive
Each student
Prime factor lock Student sheet 1
Calculator
Task
Introduce students to the relevance of prime numbers in everyday life by showing the video Catalyst: Prime number keys (2:57), which explains how prime numbers are used in banking security.
Ask: What did you notice about how prime numbers were used in the video?
Use student responses to draw out the key idea that large numbers can be built from prime numbers, and that working backwards from a large number to find the prime numbers it was built from can be difficult.
Explain that the challenge of this lesson is to develop a simplified encryption lock for a phone. Before designing their own lock, students will test how a prime-number lock could work and decide whether it generates enough possible lock numbers to be considered secure. They will then use what they discover to inform their own design.
Current largest known primes

In 1951, the largest known prime had only 79 digits. As of September 2026, the largest known prime is the Mersenne prime $2^{13627941}-1$, with 41,024,320 digits, discovered through the Great Internet Mersenne Prime Search in 2024. The subtraction of one is essential: any power of two greater than two is even and therefore composite, whereas subtracting one produces an odd number that may be prime.
The PrimePages website maintains regularly updated lists of the largest known primes and can be used for further background reading.
In 1951, the largest known prime had only 79 digits. As of September 2026, the largest known prime is the Mersenne prime $2^{13627941}-1$, with 41,024,320 digits, discovered through the Great Internet Mersenne Prime Search in 2024. The subtraction of one is essential: any power of two greater than two is even and therefore composite, whereas subtracting one produces an odd number that may be prime.
The PrimePages website maintains regularly updated lists of the largest known primes and can be used for further background reading.
Show the Prime factor lock digital interactive.
Explain that instead of using a PIN made from digits, this new lock design creates a code by multiplying numbers on a grid. This first prototype uses only prime numbers: the user swipes two adjacent primes, and the product of those two primes becomes the lock number.
Before designing their own lock, students need to test this prototype and decide whether it creates enough possible lock numbers to be considered secure.
Demonstrate the lock and explain the rules:
- A swipe uses exactly two numbers.
- The two numbers must be adjacent. They may touch horizontally, vertically, or diagonally.
- The product of the two numbers is the lock number.
- Reverse swipes count as the same combination. For example, 2 → 3 and 3 → 2 represent the same pair and should be counted only once.
Provide students with Prime factor lock Student sheet 1 and access to the Prime factor lock digital interactive.
Challenge students to find and record all possible lock numbers this system can create.
Bring the class together and invite groups to share how many lock numbers they found.
Discuss:
- What strategies helped you find the possible lock numbers?
- How did you avoid counting reverse swipes twice?
- How do you know there are no missing combinations?
Record student strategies, highlighting any that organise the search by direction or by position on the grid.
Show Slide 3 of Factor lock Slides which highlights one possible method for organising and counting swipes.
Confirm the 3 × 3 grid produces 20 two-number swipes and explain that a systematic method is required to ensure all combinations have been found.
Explain that because the grid uses different prime numbers, each pair of primes creates a different product. This means the 20 possible swipes create 20 possible lock numbers.
Discuss:
- Is 20 possible lock numbers enough for a phone lock to be considered secure?
- How many possible lock numbers would you consider enough?
- What could the designers change to create more possible lock numbers?
Use student responses to set up the next challenge:
A larger grid could create more possible lock numbers, but how much larger would it need to be to create 100, 200, or more possible lock numbers?
Explain that students will investigate how the number of possible lock numbers changes as the grid grows.
Students may suggest increasing the length of the swipe, in order to include the products of more than two numbers that are not all adjacent. Acknowledge this as a possible future improvement but explain that this prototype is testing how far the designers can get using swipes of two adjacent numbers.
Set the challenge: How large would a prime-number grid need to be to create enough possible lock numbers to be considered secure?
Revisit the numbers suggested in the previous discussion. Ask pairs to choose a target number of possible swipes to investigate, such as 100, 200, or another number, and identify the smallest grid size that meets their chosen target.
Before students begin counting, invite students to make a prediction:
If we doubled the number of rows and columns, for example, going from a 3 × 3 grid to a 6 × 6 grid, would the number of possible lock numbers also double?
Allow students time to investigate larger square grids, looking for patterns in how the number of possible lock numbers changes. Encourage them to use diagrams, tables, calculations or other representations to organise their counts and test their predictions.
Students should be ready to explain:
- how they counted the number of possible swipes.
- how they avoided counting reverse swipes twice.
- what they noticed about how the count changes as the grid grows.
- how they know they have found the smallest square grid that meets their chosen target.
Students may count by separating horizontal, vertical and diagonal swipes; by counting swipes from corner, edge and interior cells and adjusting for double counting; or by comparing how the total changes as the grid grows.
Students may begin by drawing larger grids and counting the swipes one at a time. This can help them get started, but it becomes inefficient as the grid grows.
Useful prompts:
- What stays the same as the grid grows?
- What changes when the grid increases by one row and one column?
- Can the count be broken into horizontal, vertical, and diagonal swipes?
- How could you count one type of swipe first, then use that to help count the others?
- How can you check that reverse swipes have not been counted twice?
If students need more structure, suggest that they start by comparing a 3 × 3 grid and a 4 × 4 grid.
Ask:
- How many horizontal swipes are possible in each row?
- How many rows are there?
- How many vertical swipes are possible in each column?
- How many columns are there?
- How many 2 × 2 blocks of neighbouring numbers are inside the grid?
- How many diagonal swipes are possible in each 2 × 2 block?
Students who develop a systematic counting method can try to create a rule for the number of possible two-number swipes on any $n \times n$ grid.
Ask:
- How many horizontal swipes are possible on an $n \times n$ grid?
- How many vertical swipes are possible?
- How many diagonal swipes are possible?
- How could these parts be combined into one rule?
One way to reason is to count the swipes by direction.
Horizontal swipes
Each row has $n − 1$ possible horizontal swipes between adjacent numbers. There are $n$ rows.
So the number of possible horizontal swipes is: $n \times (n − 1)$.
Vertical swipes
Each column has $n-1$ possible vertical swipes between adjacent numbers. There are $n$ columns.
So the number of vertical swipes is: $n \times (n − 1)$.
Diagonal swipes
To count the possible diagonal swipes, look for each 2 × 2 block of neighbouring numbers in the grid.
For an $n \times n$ grid, there are: $(n − 1) \times (n − 1)$ such 2 × 2 blocks. Each block contains two possible diagonal swipes.
So, the number of possible diagonal swipes is: $2 \times (n − 1) \times (n − 1)$
Combining the three parts gives:
horizontal + vertical + diagonal $= n \times (n − 1) + n \times (n − 1) + 2 \times (n − 1) \times (n − 1)$
This can be simplified to:
Total swipes $= 2(n − 1)(2n − 1)$
Going further: Creating a formula for an $m \times n$ grid
For students who have developed a formula for an $n \times n$ grid, a natural extension is to consider an $m \times n$ rectangular grid, where horizontal, vertical and diagonal adjacent swipes are allowed.
Let $m$ represent the number of rows and $n$ represent the number of columns.
The total number of possible swipes is:
$m \times (n − 1) + n \times (m − 1) + 2 \times (m − 1) \times (n − 1)$
This can be simplified to:
$4mn − 3m − 3n + 2$
Decomposition

Decomposition helps students make a productive start, reduce cognitive load, and see how different parts of a problem connect to the whole.
In this task, students decompose the problem of counting all possible swipes by considering horizontal, vertical, and diagonal swipes separately. The diagonal case can be broken down further by considering each 2 × 2 block in the grid. These smaller counts can then be combined to determine the total number of possible swipes and support generalisation to an $n × n$ grid.
Useful teacher moves when students are faced with a problem that feels large or difficult to manage:
- Ask what smaller parts the problem could be broken into.
- Help students separate what stays the same from what changes.
- Encourage students to solve one manageable case before tackling the whole problem.
- Draw attention to useful categories, sub-cases or stages in the problem.
- Revoice student strategies in ways that make the structure of the breakdown more visible.
Decomposition helps students make a productive start, reduce cognitive load, and see how different parts of a problem connect to the whole.
In this task, students decompose the problem of counting all possible swipes by considering horizontal, vertical, and diagonal swipes separately. The diagonal case can be broken down further by considering each 2 × 2 block in the grid. These smaller counts can then be combined to determine the total number of possible swipes and support generalisation to an $n × n$ grid.
Useful teacher moves when students are faced with a problem that feels large or difficult to manage:
- Ask what smaller parts the problem could be broken into.
- Help students separate what stays the same from what changes.
- Encourage students to solve one manageable case before tackling the whole problem.
- Draw attention to useful categories, sub-cases or stages in the problem.
- Revoice student strategies in ways that make the structure of the breakdown more visible.
Bring the class together and invite groups to share their chosen target and the smallest grid size they found that met it.
Record several approaches on the board, including any that use diagrams, organised counting, tables, repeated addition, or a general rule.
Discuss:
- Which grid sizes did groups test?
- How did different groups count the possible swipes?
- Did any groups notice a pattern in how the total changed?
- How did groups check that reverse swipes were not counted twice?
- How did groups decide that their grid size was the smallest one that met their target?
Use student responses to build or confirm a class table of results. Slide 4 is available to confirm the class findings.
| Grid size | Possible lock numbers | Increase from previous grid |
|---|---|---|
| 3 × 3 | 20 | - |
| 4 × 4 | 42 | +22 |
| 5 × 5 | 72 | +30 |
| 6 × 6 | 110 | +38 |
| 7 × 7 | 156 | +46 |
| 8 × 8 | 210 | +54 |
Ask:
- What do you notice about the pattern?
- The increase from the previous grid grows by eight each time.
- Does the pattern still work if we work backwards and check a smaller grid, such as 2 × 2? Can we go back any further?
- Use the 2 × 2 grid as a quick check. There are four possible side swipes in a 2 × 2 grid and two diagonal swipes, making six possible two-number swipes. This fits the pattern because moving from 2 × 2 to 3 × 3 increases the count by 14, from 6 to 20.
If students developed a general rule, use their work to confirm the count:
Total swipes $= 2(n − 1)(2n − 1)$
For an 8 × 8 grid: $2 × 7 × 15 = 210$.
Discuss:
- Would an 8 × 8 grid be practical on a phone screen?
- What are the advantages and limitations of using only prime numbers?
- What else could be changed to make the lock design more flexible?
Use student responses to draw out the key design issue:
We could scale up the prime-number lock prototype to create at least 200 possible two-number swipes, but it would need to be an 8 × 8 grid to do so. This may be too large and crowded for a practical phone screen. The design also creates only lock numbers that are products of two prime numbers.
Use this discussion to introduce the next lesson where students will investigate whether composite numbers can make the lock more flexible.
Recognising growth patterns

A linear relationship has a constant increase. For example, the perimeter of a $n \times n$ square increases by four each time the side length increases by one.
| Grid size | Perimeter | Increase | Change in the increase |
|---|---|---|---|
| 3 × 3 | 12 | – | – |
| 4 × 4 | 16 | +4 | – |
| 5 × 5 | 20 | +4 | 0 |
| 6 × 6 | 24 | +4 | 0 |
| 7 × 7 | 28 | +4 | 0 |
| 8 × 8 | 32 | +4 | 0 |
The number of possible swipes in a grid grows differently.
| Grid size | Possible two-number swipes | Increase | Change in the increase |
|---|---|---|---|
| 3 × 3 | 20 | – | – |
| 4 × 4 | 42 | +22 | – |
| 5 × 5 | 72 | +30 | +8 |
| 6 × 6 | 110 | +38 | +8 |
| 7 × 7 | 156 | +46 | +8 |
| 8 × 8 | 210 | +54 | +8 |
The swipe total does not grow linearly because the increases are not constant.
However, the increase itself rises by eight each time. This constant second difference is a feature of a quadratic relationship.
This makes sense in the context of the grid. Increasing the side length adds a new row and a new column, but the number of new horizontal, vertical and diagonal swipes increases as the grid becomes larger.
Students do not need to use the term quadratic in Year 7. The important idea is that the pattern has a changing rate of growth: each larger grid adds more new swipes than the grid before it.
The rule confirms this. For a $n \times n$ grid:
$$\text{Total swipes} = 2(n − 1)(2n − 1)$$
This can be expanded to:
$$ \text{Total swipes} = 4n^2 − 6n + 2$$
The $n^2$ term shows that the relationship is not linear, and is indeed quadratic.
Useful prompts include:
- Does the total increase by the same amount each time?
- What happens to the increases as the grid grows?
- Why does adding one row and one column create more new swipes on a larger grid?
A linear relationship has a constant increase. For example, the perimeter of a $n \times n$ square increases by four each time the side length increases by one.
| Grid size | Perimeter | Increase | Change in the increase |
|---|---|---|---|
| 3 × 3 | 12 | – | – |
| 4 × 4 | 16 | +4 | – |
| 5 × 5 | 20 | +4 | 0 |
| 6 × 6 | 24 | +4 | 0 |
| 7 × 7 | 28 | +4 | 0 |
| 8 × 8 | 32 | +4 | 0 |
The number of possible swipes in a grid grows differently.
| Grid size | Possible two-number swipes | Increase | Change in the increase |
|---|---|---|---|
| 3 × 3 | 20 | – | – |
| 4 × 4 | 42 | +22 | – |
| 5 × 5 | 72 | +30 | +8 |
| 6 × 6 | 110 | +38 | +8 |
| 7 × 7 | 156 | +46 | +8 |
| 8 × 8 | 210 | +54 | +8 |
The swipe total does not grow linearly because the increases are not constant.
However, the increase itself rises by eight each time. This constant second difference is a feature of a quadratic relationship.
This makes sense in the context of the grid. Increasing the side length adds a new row and a new column, but the number of new horizontal, vertical and diagonal swipes increases as the grid becomes larger.
Students do not need to use the term quadratic in Year 7. The important idea is that the pattern has a changing rate of growth: each larger grid adds more new swipes than the grid before it.
The rule confirms this. For a $n \times n$ grid:
$$\text{Total swipes} = 2(n − 1)(2n − 1)$$
This can be expanded to:
$$ \text{Total swipes} = 4n^2 − 6n + 2$$
The $n^2$ term shows that the relationship is not linear, and is indeed quadratic.
Useful prompts include:
- Does the total increase by the same amount each time?
- What happens to the increases as the grid grows?
- Why does adding one row and one column create more new swipes on a larger grid?