Resources For Teachers For Tutors For Students & Parents AI New Pricing
Year 6 Maths Patterns & Rules

Algorithms generating number sets

20 practice questions 0 video lessons Theory + worked examples
Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

An algorithm is a list of steps that are followed exactly, in order. A function machine applies a rule to each input; a flow chart can repeat steps and ask yes/no questions; a sequence rule makes each term from the one before. This Year 6 maths page shows how to follow these algorithms, work backwards through them, and find the rule that made a set of numbers.

An algorithm is a set of steps that always gives the same result for the same start. Computers follow algorithms.

A function machine takes an input, applies its rule and gives an output. Two-step machines apply their steps in order.

A flow chart shows the steps in boxes joined by arrows. A diamond asks a yes/no question and the answer decides which arrow to follow, so steps can repeat.

A sequence rule starts with a number and makes each new term from the term before, such as "double, then add \(1\)".

To work backwards through a machine, do the opposite steps in the reverse order.

Two-step function machine A function machine: the input 6 is multiplied by 3 to make 18, then 2 is added to give the output 20. Underneath, red arrows show the reverse steps minus 2 and divide by 3. 6 18 20 × 3 ÷ 3 + 2 − 2
Input \(6\): \(\times 3\) gives \(18\), \(+2\) gives \(20\). Backwards: \(-2\), then \(\div 3\).
Flow chart that keeps doubling A flow chart: start with 3; double it and write it down; is it more than 50? If no, go back and double again; if yes, stop. Start with 3 Double it and write it down More than 50? Stop Go back YesNo
The flow chart writes \(6, 12, 24, 48, 96\) and stops at \(96\).

Following and undoing algorithms:

\[ 6 \;\rightarrow\; 6 \times 3 = 18 \;\rightarrow\; 18 + 2 = 20 \]
6→6×3=18→18+2=20
StepOpposite step
\(+\) add\(-\) subtract
\(-\) subtract\(+\) add
\(\times\) multiply\(\div\) divide
\(\div\) divide\(\times\) multiply
Order matters. \(\times 3\) then \(-2\) turns \(6\) into \(16\); \(-2\) then \(\times 3\) turns it into \(12\).
Keep a record. Write each number down as the algorithm makes it.

Following an algorithm

  1. Start with the given number.
  2. Do each step in order, writing down each result.
  3. At a question, follow the yes or no arrow, and repeat steps when told to.

Working backwards through a machine

  1. Start from the output.
  2. Undo the last step first with its opposite, then the step before.
Example 1 — One-step machine
A machine adds \(6\). What is the output when the input is \(13\)?
Solution
\(13 + 6\)\(=\)\(19\)
13+6=19

\(19\).

Example 2 — Multiply machine
A machine multiplies by \(5\). What is the output for input \(7\)?
Solution
\(7 \times 5\)\(=\)\(35\)
7×5=35

\(35\).

Example 3 — Two steps
Use the first diagram. What is the output for input \(6\)?
Solution
\(6 \times 3 + 2\)\(=\)\(20\)
6×3+2=20

\(20\).

Example 4 — Work backwards
A machine multiplies by \(2\), then adds \(5\). The output is \(29\). What was the input?
Solution
\(29 - 5\)\(=\)\(24\)
\(24 \div 2\)\(=\)\(12\)
(29−5)÷2=12

\(12\). Check: \(12 \times 2 + 5 = 29\).

Example 5 — Sequence from a rule
A sequence starts at \(4\) and the rule is add \(6\).
(i) What is the 3rd term?
(ii) What is the 6th term?
Solution
\(4 + 2 \times 6\)\(=\)\(16\)
\(4 + 5 \times 6\)\(=\)\(34\)
16 and 34

(i) \(16\)
(ii) \(34\) (the sequence is \(4, 10, 16, 22, 28, 34\))

Example 6 — A two-step sequence rule
A sequence starts at \(2\). Its rule is "double the number, then add \(1\)". Write the first four terms.
Solution
\(2 \times 2 + 1\)\(=\)\(5\)
\(5 \times 2 + 1\)\(=\)\(11\)
\(11 \times 2 + 1\)\(=\)\(23\)
2,5,11,23

\(2, 5, 11, 23\).

Example 7 — Flow chart
Follow the flow chart in the second diagram. Which numbers are written down, and how many times is the question asked?
Solution

\(6, 12, 24, 48, 96\). The question is asked \(5\) times; only \(96\) is more than \(50\), so the chart stops there.

Example 8 — Find the rule
A rule turns \(2, 3, 4, 5\) into \(9, 11, 13, 15\). What is the rule?
Solution

The outputs go up by \(2\), so multiply by \(2\). \(2 \times 2 = 4\) and \(9 - 4 = 5\).

Multiply by \(2\), then add \(5\).

Example 9 — Find the mistake
A machine multiplies by \(3\), then subtracts \(2\). Leo put in \(6\), subtracted first and got \(12\). What is right?
Solution
\(6 \times 3 - 2\)\(=\)\(16\)
6×3−2=16

The steps must be done in order: \(\times 3\) first. The output is \(16\).

Common pitfalls

Doing the steps out of order. A machine applies its steps in the order shown.
Working backwards in the same order. Undo the last step first.
Stopping a flow chart too early. Keep repeating until the answer to the question sends you to stop.
Using the term number instead of the term. Each new term is made from the term before it.

Frequently asked questions

What is an algorithm?

A set of steps followed exactly, in order, that always gives the same result for the same start.

What does a function machine do?

It applies the same rule to every input to make an output.

How do I find the input from the output?

Use the opposite steps in reverse order.

What does a diamond in a flow chart mean?

A yes/no question; the answer decides which arrow to follow.

What is the rule if 2, 3, 4, 5 become 9, 11, 13, 15?

Multiply by \(2\), then add \(5\).

How would you describe the set 4, 8, 12, 16, 20?

The multiples of \(4\): start at \(4\) and add \(4\) each time.