Loops (cyclic algorithms)
About this lesson

There are three main kinds of algorithm. In a linear algorithm the steps run one after another, once each. In a branching algorithm a condition decides which action is taken. In a cyclic algorithm some actions are repeated again and again. A repeated sequence of actions is a loop, and an algorithm containing one is a cyclic algorithm. For example, to draw a square, instead of writing “forward 50, right 90” four times, we use a loop: REPEAT 4 TIMES: forward 50, right 90. The commands inside the loop are indented so it is clear which ones repeat. If the number of repeats is not known in advance, we write a loop condition: REPEAT WHILE the cell is not coloured: colour the cell, move forward. The loop continues while the condition holds and stops when it doesn’t. In a flowchart a loop is shown by an arrow going back: the condition is checked; if “yes”, the loop body runs and the check repeats; if “no”, the loop ends. Loops make algorithms shorter, reduce mistakes and make changes easier. Life is full of cycles too: day and night, the seasons, laps in sport.
What the book shows
In grade 6 the computer science textbook covers how a computer is built and works, encoding numbers, electronic presentations, the properties of algorithms and loops, variables in programs, and email. Each topic gives a short explanation, an example and a task done on or off the computer.
Textbook link:
This is not the textbook’s text but a short description of the topic. Check the exact page in your own textbook.
The lesson step by step
- 1
Warm-up5 min
A robot running laps.
- 2
New topic10 min
Three kinds of algorithm.
- 3
Practice10 min
REPEAT n TIMES.
- 4
Game10 min
Loop condition and flowchart.
- 5
Wrap-up5 min
Shortening an algorithm.
Let’s understand
For the student Simple language

| Type | How it works | Example |
|---|---|---|
| linear | steps once, in order | make breakfast |
| branching | choice by condition | if it rains, take an umbrella |
| loop (count) | repeat n times | REPEAT 4 TIMES: forward 50, right 90 |
| loop (condition) | repeat while true | while there are beads, pick one |
For the parent
How to help
- Play “find the loop”: what repeats in a song, a dance or daily chores, and how many times?
For the teacher
Lesson goals
- Tell linear, branching and cyclic algorithms apart, find the repeated part of an algorithm, use “repeat n times” and “repeat while” commands, and show a loop in a flowchart.
How to teach it
- Hands-on computer work, unplugged modelling, pair work, mini-project
Differentiation
- Weaker pupils follow the model step by step; stronger pupils design and test their own task
Questions for the class
- Instead of writing a step ten times, what can we do?
How to check
The pupil tells kinds of algorithm apart, finds the repeated part, writes count and condition loops, and shows a loop in a flowchart.
Scientific Scientific language
Cycles in nature
The water cycle (evaporation → cloud → rain → river → sea) is a natural loop.
The heart
The heart repeats the same cycle with every beat.
Self-study
Step by step
- I told the three kinds apart.
- I found the repeated part.
- I used a REPEAT command.
- I drew a loop as a flowchart.
Going deeper
Scientific language: for older students, parents and teachers.
A loop can contain another loop — a nested loop; for example, repeating the square loop 3 times to draw 3 squares.
Play and check
Which kind of algorithm?
How to write it down
- Write loop algorithms for drawing a square and an equilateral triangle.
- Write 3 cycles from everyday life.
- Draw a flowchart for “climb 10 stairs”.
How the classwork looks in the notebook
Sample: the date and heading follow this country’s notebook rules.
Watch out: common mistakes
Where it helps in life
- Variables in a program
At home
Core
- Write a loop algorithm from daily life (e.g. planting flowers) and indent the repeated part.
Extra ⭐
- How many repeats and what angle are needed to draw a hexagon?
How to do it
- Do the task with a grown-up.
- Explain in words what you noticed.
Answers for parents
Square: REPEAT 4 TIMES: forward 50, right 90. Triangle: REPEAT 3 TIMES: forward 50, right 120. Hexagon: REPEAT 6 TIMES: forward 50, right 60 (360 ÷ 6 = 60).
Step-by-step homework solution — Show the solution (try it yourself first)
Let’s shorten it
- Long version: “forward 30, right 72” written out five times. The repeated pair is “forward 30, right 72”, 5 times. Short version: REPEAT 5 TIMES: forward 30, right 72. The result is a pentagon (72 × 5 = 360).
How the homework looks in the notebook
Sample: the date and heading follow this country’s notebook rules.