Highest Common Factors – Euclid's algorithm

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.

Scratch code image

  1. The loop in Python needs to be a WHILE loop
  2. Just like in Euclid's algorithm, we keep going all the time the variables are NOT EQUAL TO each other
  3. In Python NOT EQUAL TO is !=
  4. Then we check which number is biggest and take the smallest number away from the biggest number
  5. Don't forget to indent code carefully
  6. IMPORTANT: don't forget what your Python variables are called!

  7. Save your program
  8. Run your program
  9. Run it several times to check it always works right and to correct any errors

Code helper image