Highest Common Factors – Euclid's algorithm

Step 4 – printing the answer

The last part of the program simply prints out the Highest Common Factor.

Scratch code image

This is just one line of Python code. It shouldn't be indented at all.

Code helper image

THEORY: We're printing the value of a variable here.

Once this is programmed you need to:

  1. Save your program
  2. Run your program several times
  3. Try simple numbers and bigger ones.
  4. Try a prime number. The HCF should always be 1 if either of the numbers you enter are prime numbers

That's the basic program done. Click here to extend it to three numbers