Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the flowchart for each pair of inputs. MOD gives the remainder. If Y is greater than Z use A ← Y MOD Z, otherwise A ← Z MOD Y. A = 0 gives Valid, anything else gives Invalid. The algorithm ends when Y = 0.
| Y | Z | A | OUTPUT |
|---|---|---|---|
| 11 | 4 | 3 | Invalid |
| 6 | 2 | 0 | Valid |
| 3 | 9 | 0 | Valid |
| 3 | 2 | 1 | Invalid |
| 2 | 6 | 0 | Valid |
| 0 | 0 |
Y column correct [1]
Z column correct [1]
A column correct [1]
OUTPUT column correct [1]
Write two of these:
It checks if the remainder is zero when the larger number is divided by the smaller number [1]
It checks if the larger number is a multiple of the smaller number (or the smaller number is a factor of the larger) [1]
Any two of these points score.
▶ Topic lesson
A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.