Algorithms that generate number sequences
Theory
An algorithm is a set of steps that makes a number sequence: it has a start number and a rule you repeat, such as add 4 each time, double each time, or a two-step rule like double then add 1. This Year 4 maths page shows how to generate a sequence, find the next or the fifth number, and work out the rule from a sequence. Curriculum: VC2M4N10 / AC9M4N09.
An algorithm is a set of steps you follow to make a number sequence. It always has two parts: a start number and a rule that you use again and again.
The start number is the first number in the sequence. The rule tells you what to do to one number to get the next number. To make the sequence, apply the rule to the last number, then keep going. For "start at 2 and add 4 each time" you get \(2,\ 6,\ 10,\ 14,\ \ldots\)
A rule can add the same amount, take away the same amount, double each number, or use a two-step rule such as "double, then add 1". Each number you make is called a term.
Every algorithm for a sequence has a start number and a rule. These facts help you use and test them.
How to make a sequence from an algorithm
- Write the start number. This is the first term of the sequence.
- Apply the rule. Do what the rule says to the last number to get the next number.
- Repeat. Use the same rule again and again until you have as many terms as you need.
| \(21 + 5\) | \(=\) | \(26\) |
Apply the rule to the last term, so the next number is \(26\).
| \(5 \times 2\) | \(=\) | \(10\) |
| \(10 \times 2\) | \(=\) | \(20\) |
| \(20 \times 2\) | \(=\) | \(40\) |
Each number is double the one before, so the rule is double each time.
| \(28 - 6\) | \(=\) | \(22\) |
| \(22 - 6\) | \(=\) | \(16\) |
The terms are \(40,\ 34,\ 28,\ 22,\ 16\). The fifth number is \(16\).
| \(17 \times 2\) | \(=\) | \(34\) |
| \(34 - 1\) | \(=\) | \(33\) |
Double first, then take away 1, so the next number is \(33\).
| \(3 \times 4\) | \(=\) | \(12\) |
| \(5 \times 4\) | \(=\) | \(20\) |
| \(7 \times 4\) | \(=\) | \(28\) |
| \(36 \div 4\) | \(=\) | \(9\) |
The rule multiply by 4 works for every row. To get \(36\) out, run it backwards: \(9\) goes in.
| \(50,\ 46,\ 42,\ 38,\ 34,\ 30\) | ||
| \(30,\ 26,\ 22,\ 18\) |
\(30\) is the sixth number, so it appears. The sequence goes from \(22\) to \(18\), jumping over \(20\), so \(20\) does not appear.
Common pitfalls
Frequently asked questions
What is an algorithm in maths?
An algorithm is a set of steps that makes a number sequence. It has a start number and a rule you repeat, such as add 4 each time or double each time. You use the rule on the last number to get the next number.
How do you use an algorithm to make a number sequence?
Write down the start number, then apply the rule to get the next number. Keep applying the same rule again and again. For "start at 7 and add 3" you get \(7,\ 10,\ 13,\ 16\) and so on.
How do you find the next number in a sequence?
Apply the rule to the last number you have. For \(6,\ 11,\ 16,\ 21\) the rule is add 5, so the next number is \(21 + 5 = 26\).
How do you work out the rule for a number sequence?
Compare each number with the one before it. If it goes up by the same amount the rule is add that amount. If it goes down the rule is take away. If each number is double the one before, the rule is double each time.
What is a two-step rule?
A two-step rule does two things in order, such as double, then add 1. You must do the steps in the right order. Starting at 4 with double then add 1 you get \(4,\ 9,\ 19,\ 39\).
How do you find the fifth number in a sequence?
Start at the first number and apply the rule until you reach the fifth term. For "start at 40 and take away 6" you get \(40,\ 34,\ 28,\ 22,\ 16\), so the fifth number is \(16\).