Idea 6of 23Builds onA loop repeats the lines inside it
Counting with a loop
How can a loop count, or skip count?
Today you'll discover
- how a loop counts by 1s
- how it skip counts
- why a loop can multiply
Think firstSET 0, then REPEAT 5 TIMES: ADD 1
What does count hold when the loop is done?
Decide first, then press Next. Each bar is the count after one more pass.
Code: SET 0, REPEAT 5 TIMES, ADD 1, END, OUTPUT, with bars for 0, 1, 2, 3, 4 and 5. Then the same loop with ADD 4: bars for 0, 4, 8, 12, 16 and 20, and the working 5 passes times 4 equals 20. The last step asks about 3 cartons of 6 eggs counted with a loop.
See the whole ideathe big idea and the key word, in one place
The big idea
A loop that adds the same amount on every pass counts: 5 passes of 4 make 20.
Counting by 4s
Each pass adds 4: the count goes 4, 8, 12, 16, 20.
- pass 14
- pass 28
- pass 312
- pass 520
Easy to get wrongStart the count at 0 with SET 0. Without it, the loop adds on top of whatever number was already in the box.
Key word
- counter
- a variable that goes up by the same amount each time something happens, to count it
Ready to use it?
- Use a loop to skip count, and write the multiplication it makes.