Highest Common Factors – Euclid's algorithm

Step 1 – The Scratch code

Once again, I can program this in Scratch.

Code helper image

Take a look at the code. Can you see what it does?

The Scratch code actually takes more lines and is a bit more complex than the Python code will be. There are two reasons for this:

  1. Scratch needs two lines to get a number from the user and store it away. Python can do this in a single line
  2. Scratch can't use a WHILE loop. It has to use a REPEAT – UNTIL loop, which is a little bit more complicated

So, let's code this in Python.