Error: loop repeats one time too many or too few
A bug where a repeat count or stop test is wrong by one, such as count > 5 instead of count = 5, so the loop body runs one time too many or one time too few.
Understanding Error: loop repeats one time too many or too few in ACARA Digital Technologies Years 7–8
What it does: The counter goes 0→1, 1→2, 2→3, 3→4, 4→5 and then stops. That is 5 passes, so the trace table has exactly 5 loop rows. With count = 5 the loop stops as soon as count reaches 5, so the body only runs 4 times (count = 1, 2, 3, 4). Using count > 5 lets it run for 1, 2, 3, 4 and 5. The algorithm runs, but the stop test is wrong by one, so the body repeats one extra time. That makes it a logic error.
Common mistakes: Count starts at 1, so the loop must run until count has gone past 5. Stopping when count = 5 ends the loop one time too early, so 5 is never added. It should be REPEAT UNTIL count > 5. The laps should be 1 to 5, so lap must start at 1. Starting at 0 makes the loop run 6 times, one time too many, and the trace table gets an extra row. It should be SET lap ← 1.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 420–481) and word search (Modules 420–519).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
off-by-one errorFill in the Blanks
Spot the Error
Student with a class code? Join your class →