MyLeoNes™

Mathematics Year 7: Computational thinking with sequences

Mathematics, Year 7 (Portugal): Abstract, decompose, spot a pattern, write an algorithm and debug it, all on one question: is this number a term of the sequence?

Five tools, one question

Question: is 98 a term of the sequence −7, −4, −1, 2, …? Abstract: keep only what matters, the first term (−7) and the step (+3). Decompose: find the rule, undo it, check the result, three simple stages. Spot patterns: you have met “first term plus a constant step” before. Algorithm: write steps that work for any value, not only 98. Debug: test the steps on known cases and correct what fails. The rule here: term n is 3 × n − 10.

A pattern you can reuse

A theatre has 14 seats in row 1 and 2 more in each next row, so row n has 2 × n + 12 seats: 14, 16, 18, 20… Is there a row with exactly 50 seats? Same shape as the sequence before, so the same steps: subtract 12 (38), divide by 2 (19), and 19 is a natural number: yes, row 19. And 51? 51 − 12 = 39, 39 ÷ 2 = 19.5, not a position: no. Recognising the pattern lets you reuse the procedure: only the numbers change (add 10 and divide by 3 became subtract 12 and divide by 2).

A case: the algorithm for “is x a term?”

Sequence −7, −4, −1, 2, … with term 3 × n − 10. Algorithm: 1) add 10 to x; 2) divide by 3; 3) if the result is a natural number (1, 2, 3, …), x is the term in that position; if not, x is not a term. Case x = 98: 98 + 10 = 108 and 108 ÷ 3 = 36, so 98 is the 36th term. Check: 3 × 36 − 10 = 98 ✓. Case x = 100: 100 + 10 = 110 and 110 ÷ 3 = 36.67…, not a natural number, so 100 is not a term (the 36th is 98 and the 37th is 101).

It passed two tests, so it must be right

Rui's version of the algorithm says: “add 10, divide by 3, and if the result is a whole number, x is a term”. It worked for 98 and 100. Debugging means hunting for hard cases. Try x = −10: −10 + 10 = 0, 0 ÷ 3 = 0, a whole number, so it says “yes”. But the first term is −7, in position 1, and there is no position 0. The same happens with −16 (position −2). The fix: also check that the result is at least 1. Test the edges: the first term, values before it, values in between.

Where you see it: spreadsheets and programs

In a spreadsheet, put the positions 1 to 8 in column A and type =3*A1-10 in column B: −7, −4, −1, 2, 5, 8, 11, 14. A rule became a procedure a machine repeats without thinking. Programmers do what you did: split the task into small blocks, test each with easy and awkward values (the first, the last, zero, negatives) and fix the block that fails. Checking whether a value belongs to a list built by a rule is a job programs often do.

Test what you learned

  1. In the problem “is 98 a term of −7, −4, −1, 2, …?”, which action is abstraction?

    • a) Splitting the work into three stages: find the rule, undo it, check
    • b) Testing the steps on a term you already know, such as 14
    • c) Keeping only the first term −7 and the step +3, and setting the rest aside
    • d) Using the same steps later for the seats of a theatre

    Correct answer: c) Keeping only the first term −7 and the step +3, and setting the rest aside — Right: abstraction extracts the essential information; here the first term and the step are all you need.

  2. The sequence −7, −4, −1, 2, … has term 3 × n − 10. Using the algorithm (add 10, divide by 3, the result must be a natural number), which number is a term?

    • a) 60
    • b) 61
    • c) 64
    • d) 62

    Correct answer: d) 62 — Right: 62 + 10 = 72 and 72 ÷ 3 = 24, so 62 is the 24th term. Check: 3 × 24 − 10 = 62.

  3. Rui's algorithm (add 10, divide by 3, “a whole result means x is a term”) says x = −10 is a term of −7, −4, −1, 2, … What is the bug?

    • a) It never checks the position is at least 1: (−10 + 10) ÷ 3 = 0, and there is no position 0
    • b) It should divide by 10 instead of 3
    • c) There is no bug: −10 would come before −7, so it is a term
    • d) It should not add 10, because the first term is −7

    Correct answer: a) It never checks the position is at least 1: (−10 + 10) ÷ 3 = 0, and there is no position 0 — Right: the first term is in position 1, so a result of 0 (or a negative one) means x is not in the sequence.

Keep exploring

Other languages

Loading MyLeoNes™…