Math · Foundational · Lesson 8 of 9
Loops with Memory
Counters, totals and off-by-one
An interactive lesson with 7 steps, about 6 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.
What you’ll learn
- An accumulator starts at 0 and a loop keeps adding to it.
- range(a, b) runs from a up to b − 1: b − a values.
- Off-by-one (fencepost) errors hide in loop limits; test small cases.
Steps
- Running totals
- Adding squares
- Reaching 55
- Fenceposts
- How many times?
- The biggest so far
- Counting multiples