Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the flowchart once for each input. Calc1 and Calc2 use DIV, so they drop any remainder. A value is output only when Calc1 = Value / 2 and Calc2 = Value / 3, which means Value divides exactly by 2 and by 3. Input -1 ends the algorithm.
| Value | Calc1 | Calc2 | OUTPUT |
|---|---|---|---|
| 50 | 25 | 16 | |
| 33 | 16 | 11 | |
| 18 | 9 | 6 | 18 |
| 15 | 7 | 5 | |
| 30 | 15 | 10 | 30 |
| -1 |
Value column correct [1]
Calc1 column correct [1]
Calc2 column correct [1]
OUTPUT column correct [1]
The algorithm outputs each input value [1]
that is divisible by 6 (divisible by both 2 and 3). [1]
▶ 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.