Step 3 – the loop and taking numbers away
The business part of the program is the loop.
Remember, all this does is take numbers away from each other until they are the same.
- The loop in Python needs to be a WHILE loop
THEORY: The loop uses the key idea of repetition – doing a series of instructions more than once.
- Just like in Euclid's algorithm, we keep going all the time the variables are NOT EQUAL TO each other
- In Python NOT EQUAL TO is !=
THEORY: This is using selection. We're choosing a path to take in the program.
- Then we check which number is biggest and take the smallest number away from the biggest number
THEORY: This changes the value of one of the variables each time.
- Don't forget to indent code carefully
- IMPORTANT: don't forget what your Python variables are called!
- Save your program
- Run your program
- Run it several times to check it always works right and to correct any errors