 # Iterations

Lesson Have you ever heard someone say "to reiterate"? Do you know what they mean? To reiterate is to repeat something.

Sometimes Algorithms contain steps that are repeated numerous times.  These repeated steps are called iterations or loops.

For example the steps involved in brushing your teeth could be written as:

1. Squeeze a small amount of toothpaste onto toothbrush
2. Lift toothbrush into your mouth
3. Brush one tooth
4. Move to next tooth
5. Repeat steps 3 and 4 until all teeth have been brushed
6. Take toothbrush out of your mouth
7. Wash remaining toothpaste from toothbrush

When we talk about iterations in maths, we are talking about repeating something. If I say there have been 5 iterations of something, it means it has happened 5 times. The important thing is that each time the iteration happens it is building on the previous result.

Let's go through an example to make this clearer.

$4$4 times table:

I can write an algorithm for writing down the four times table like this:

1. Start with the number $0$0
2. Add $4$4 to this number
3. Repeat step 2 eleven more times.

If we did this I would get $0$0$4$4, $8$8, $12$12, $16$16, $20$20 , $24$24, $28$28, $32$32, $36$36, $40$40, $44$44, $48$48.  This is $12$12 iterations of add $4$4

Another word that is often used to describe an iteration is a loop. If you loop through something then you are repeating it.

This is a really great way to make use of a computer - if I asked you to keep repeating the same task over and over again you would quickly get bored, right? Well a computer won't ever get bored.

#### Worked examples

##### QUESTION 1

Nadia follows an algorithm to eat her breakfast.

1. Place bowl and spoon on the table
2. Pour cereal into the bowl
3. Pour milk into the bowl
4. Spoon a mouth of cereal into your mouth
5. Repeat step 4 until the cereal is finished
6. Place bowl and spoon in the sink
1. Does this algorithm contain a loop?

No

A

Yes

B
2. Which two steps form the loop? Write both steps on the same line, separated by a comma.

##### QUESTION 2

$1$1 Start with the number $29$29 $\editable{}$
$2$2 Subtract $1$1 from this number $\editable{}$
$3$3 Repeat step $2$2 three more times $\editable{}$
$\editable{}$
$\editable{}$
$4$4 Double the number $\editable{}$