Highest Common Factors – Euclid's algorithm

Step 2 – input the two numbers

In the first part of the program we need to get the user to enter two numbers.

Scratch code image

Start by opening Python.

  1. Make sure that you go File > New File to get a blank Python program
  2. Getting two numbers entered is quicker in Python, but make sure you type the code accurately. It's easy to miss a bracket off the end

    I'm giving you this code as it's slightly tricky

    Code helper image

    Note that my two variables are called number1 and number2

  3. Save your program
  4. Run your program

THEORY: I'm using two variables here to store the values of the two numbers I want to find the HCF for.
The key programming idea is sequence. I need to get the instructions in the right order.

Now that we have the two numbers, the main bit of the program comes next.