Choose a country
Grade 6Computer scienceAlgorithms

Loops (cyclic algorithms)

Lesson goal: 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.
← 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.

Lesson goal: 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.

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. 1

    Warm-up5 min

    A robot running laps.

  2. 2

    New topic10 min

    Three kinds of algorithm.

  3. 3

    Practice10 min

    REPEAT n TIMES.

  4. 4

    Game10 min

    Loop condition and flowchart.

  5. 5

    Wrap-up5 min

    Shortening an algorithm.

Let’s understand

For the student Simple language

TypeHow it worksExample
linearsteps once, in ordermake breakfast
branchingchoice by conditionif it rains, take an umbrella
loop (count)repeat n timesREPEAT 4 TIMES: forward 50, right 90
loop (condition)repeat while truewhile there are beads, pick one
loop = repeated steps

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

  1. Write loop algorithms for drawing a square and an equilateral triangle.
  2. Write 3 cycles from everyday life.
  3. Draw a flowchart for “climb 10 stairs”.

How the classwork looks in the notebook

15 November1Classwork2linear · branching · cyclic · loop = repeated steps · REPEAT n TIMES · REPEAT WHILE condition · indent the loop body · flowchart: arrow going back · polygon: angle = 360 ÷ n3
Writing order: 1 Date 2 Heading 3 Line 3: linear · branching · cyclic · loop = repeated steps · REPEAT n TIMES · REPEAT WHILE condition · indent the loop body · flowchart: arrow going back · polygon: angle = 360 ÷ n
Sample: the date and heading follow this country’s notebook rules.

Open notebook

Watch out: common mistakes

Putting a non-repeating step inside the loop. Only repeated steps are indented.
A condition that never changes. The loop never ends — finiteness is broken.

Where it helps in life

  • Variables in a program

At home

Core

  1. Write a loop algorithm from daily life (e.g. planting flowers) and indent the repeated part.

Extra ⭐

  1. How many repeats and what angle are needed to draw a hexagon?

How to do it

  1. Do the task with a grown-up.
  2. 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)
  1. Let’s shorten it

    1. 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

15 November1Homework2Loops3
Writing order: 1 Date 2 Heading 3 Line 3: Loops
Sample: the date and heading follow this country’s notebook rules.

Check yourself