Algorithms generating number sets
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.
Following and undoing algorithms:
| Step | Opposite step |
|---|---|
| \(+\) add | \(-\) subtract |
| \(-\) subtract | \(+\) add |
| \(\times\) multiply | \(\div\) divide |
| \(\div\) divide | \(\times\) multiply |
Following an algorithm
- Start with the given number.
- Do each step in order, writing down each result.
- At a question, follow the yes or no arrow, and repeat steps when told to.
Working backwards through a machine
- Start from the output.
- Undo the last step first with its opposite, then the step before.
| \(13 + 6\) | \(=\) | \(19\) |
\(19\).
| \(7 \times 5\) | \(=\) | \(35\) |
\(35\).
| \(6 \times 3 + 2\) | \(=\) | \(20\) |
\(20\).
| \(29 - 5\) | \(=\) | \(24\) |
| \(24 \div 2\) | \(=\) | \(12\) |
\(12\). Check: \(12 \times 2 + 5 = 29\).
(i) What is the 3rd term?
(ii) What is the 6th term?
| \(4 + 2 \times 6\) | \(=\) | \(16\) |
| \(4 + 5 \times 6\) | \(=\) | \(34\) |
(i) \(16\)
(ii) \(34\) (the sequence is \(4, 10, 16, 22, 28, 34\))
| \(2 \times 2 + 1\) | \(=\) | \(5\) |
| \(5 \times 2 + 1\) | \(=\) | \(11\) |
| \(11 \times 2 + 1\) | \(=\) | \(23\) |
\(2, 5, 11, 23\).
\(6, 12, 24, 48, 96\). The question is asked \(5\) times; only \(96\) is more than \(50\), so the chart stops there.
The outputs go up by \(2\), so multiply by \(2\). \(2 \times 2 = 4\) and \(9 - 4 = 5\).
Multiply by \(2\), then add \(5\).
| \(6 \times 3 - 2\) | \(=\) | \(16\) |
The steps must be done in order: \(\times 3\) first. The output is \(16\).
Common pitfalls
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.