Today’s part two of our dive into number theory. For those who haven’t read part one about the division algorithm click here, because we plan to use it! We talk everything Euclidiean, except for Euclidean geometry! We will learn about another algorithm which is a very useful tool to find common divisors of two integers. More than that, it can be used to find all combinations of those integers! But I’m getting ahead of myself. We start at the beginning and discuss the Euclidean Algorithm and the greatest common divisor.
Some Notation
Like any branch of mathematics, there are certain notation conventions that are used. Number theory is no different. We want a shorthand for when a number is a divisor of another number.
For example, 5 is a divisor of 15. Likewise, 24 is a divisor of 96. Another way to say these two facts is: 5 divides 15 and 24 divides 96. The way we write this shorthand is the following:
Notation: Let
andbe integers such thatfor some integer, then we saydividesAnd we write. Hence the following two are equivalent statements:
We can also say
is a multiple of.(NOTE:
are all integers)
With the numbers we were using we’d write:
since
and
since
Since and are integers.
The Greatest Common Divisor
When I was in school, I would always confuse the greatest common divisor and the least common multiple. Both are important (and related to one another), but we will focus on the greatest common divisor today.1
If you remember from school, the greatest common divisor of integers and is the largest number that divides both and . For example, the greatest common divisor of 30 and 42 is equal to 6, since (i) both 30 and 42 are divisible by 6 and (ii) no number larger than 6 divides 30 and 42.
In elementary school the way I found the greatest common divisors was by listing the divisors of each number and finding the integers common to both lists. Using 30 and 42 again, I would have done the following:
Where the boxed numbers are the ones that are common between the two lists. Then I’d search for the greatest common number on the lists. In this case, it was 6. Thus, the greatest common divisor of 30 and 42 is equal to 6. Not bad…
This method is surefire; however, it’s not the best thing we can do. For example, if I gave you the numbers 1,231,872,638,162 and 9,287,391,721,397. How would you write out the factor lists? You’d need to know the prime factorization of both numbers to even start. Not good.
This is where the Euclidean Algorithm comes into play. It’s a set of steps that allow us to find the greatest common divisor of two numbers without needing to do any factorization. However, it can require a lot of steps and sometimes it would be easier to just factor, so it’s not perfect. For example, if all I needed was the greatest common divisor of 30 and 42, I would not use the Euclidean Algorithm, because factoring 30 and 42 is easy. But for numbers like 1,231,872,638,162 and 9,287,391,721,397, I would use Euclidean Algorithm because factoring these numbers is much harder to do.
The Euclidean Algorithm also has some other advantages. But let’s leave this for the section Mysterious Motivation.
Before we move on, let’s write out the definition of the greatest common divisor.
Definition: The greatest common divisor
of two integers,andis the unique integer that satisfies:
- It’s a divisor of both
and, ieand, and- For any other common divisor
where bothand, it must be.If
satisfies both criteria then we write
From before, and . And all the common factors of 30 and 42 are {1, 2, 3, 6}. Note how they are all smaller than or equal to 6.
NOTABLE EXAMPLE: Let us consider when is a multiple of ie when for some integer . What’s Well, since (1) by construction and since we have ; and (2) no number larger than can divide (so that is the largest divisor of ). We conclude 2 Remember this for later: implies .
The Euclidean Algorithm
This algorithm notationally is very confusing, however, actually doing it isn’t so bad once you get the hang of it. The idea is the following:
We have integers and with . Goal: find the greatest common divisor of and . First, we use the division algorithm to conclude,
Next, focus on the remainder . There are two things that can happen, either or . When we are done!3 Since this means that is a multiple of because . So we conclude (remember what I said to remember for later?)! So let us assume that .
Here’s the key: We claim, that if then .
If that’s true, since , we can instead work with the smaller integers and when finding the greatest common divisor of and . This is useful because we might be able to factor and .
However, sometimes we still cannot factor and . But don’t fret, since we can play the same game with the division algorithm:
Like earlier, if then and we would conclude and be done. If we’re not so lucky and , we claim something similar to earlier:
We claim, if then .
Like before, so we can begin working with even smaller integers when finding !
We might now be able to factor and , but who cares! This is too much fun! So, if let’s do the same thing again . . .
. . . and again, and again, and again, as long as the remainders are nonzero. Let’s not worry if we can factor our new smaller numbers at each step.
We’d end up with something like this:

We’d get some remainder and finally, be done. Then since all the previous remainders are nonzero, () We claim we get the chain:
with decreasing integers: .
Since , we deduce since implies is a multiple of just like earlier.
And where done!
But did you notice that we just implicitly assumed that at some point these steps would come to an end when a remainder would equal zero, in this case . But does this ever not happen? No, since all of these remainders are greater than or equal to zero and all of them are strictly smaller than the previous, they form a set of decreasing integers:
.
And since there are only finitely many integers less than but greater than 0 (namely ) the process must come to an end because some remainder reaches zero.
If every claim made above is true, then we’re done! We have found The greatest common divisor, without factoring! This is the Euclidean algorithm. We progressively use the division algorithm in order to find smaller and smaller numbers to use to find the greatest common divisor, which ends up being the last nonzero remainder from the division algorithm.
Let’s do an example and then we’ll go through the proof. But, to make the algorithm easier to follow, here is a schematic:

Where you conclude .
Example 1: gcd( 59 , 301)
Remember, we progressively use the division algorithm, and the last nonzero remainder is the greatest common divisor.

Thus,
Example 2: gcd ( 142 , 262) =2

Thus
Euclidean Algorithm “Proof”
Lemma:
Let
andbe positive integers withIf.
, then.
Proof of Lemma: (Click in the Discovery)
Let and be positive integers with . Let’s label and . Our goal is to show that . We’ll accomplish this by showing:
is divisor of and if and only if is a divisor of and .
Or, the set of divisors of and is the same as the set of divisors of and .
Why would this imply ?
We know is a divisor of both and (since it’s their greatest common divisor), and the statement above implies that also a divisor of and . But recall that is the greatest common divisor of and and therefore by part (2) of the definition of the greatest common divisor. A similar argument shows and hence .
So, if we can prove the set of divisors of and is the same as the set of divisors of and , then we’re done!
Forward: If is divisor of and then is a divisor of and .
Consider some divisor of and . By the definition of a divisor, and is equivalent to saying and for integers and .
Recall the division algorithm tells us there exists integers and such that:
.
Solving for we get,
.
Using our knowledge that and we conclude,
.
Hence is a divisor since has the form: .
Backwards: If is divisor of and then is a divisor of and .
The proof of the backward direction is the same as the forward direction, for the most part… So, I challenge you to finish this proof!
Conclusion: Since is divisor of and if and only if is a divisor of and , it must be that from the reasoning that we used earlier.
We now have enough to prove the next theorem!
Theorem: The Euclidean Algorithm really works…
Proof Idea: By repeatedly applying the division algorithm we end up with a chain of remainders with the property that each one is less than the previous. Since each remainder is greater than or equal to 0, this chain must come to an end because there are only finitely many integers less than but greater than 0.

Let’s say . Therefore,
.
By applying our lemma at each step, the greatest common divisor is ‘carried along’ each step, meaning:
Where we used that implies,
.
Thus, as stated.
A Motivating Mystery
Ok, so we have the Euclidean Algorithm now. We know how to use it, is it good for anything? Yes. It can be used to answer the following questions:
Let’s consider,
.
Are there integer solutions? Meaning are there integers and that make this true? (For example and don’t work since they give ).
Give it a try!
I’ll wait…
Did you find any?
No?
Does that mean you didn’t try enough, or are there no solutions?
Ok, try this one:
.
It’s almost the same as the first.
Give it a go!
Did you find any?
Maybe x = -2 and y = 1: since . Or maybe you found x=3 and y=-1 since . Or maybe you found another one that wasn’t either of the two above!
The first equation has no solutions whereas the second one has infinitely many solutions.
What’s the problem with the first equation, why are there no solutions? And what’s so nice about the second equation that allows for infinitely many solutions?
Unfortunately, this blog is tooooo long as it is. So, you’ll have to wait until next week! Try to come up with a conjecture of your own. Remember it’s all about a Kick in the Discovery!
TO BE CONTINUED…
Closing Remarks
Though you may think that the Euclidean Algorithm isn’t very useful in an age when you can just ask Wolfram Alpha to find the greatest common divisor of any two integers you want, and you’re partly right since most computations and arithmetic are no longer done by hand (unless you are taking a test and your teacher doesn’t allow calculators, in which case that stinks and I’m sorry!)4 The utility of the Euclidean Algorithm is in its application to theory. As well see next time, it has far-reaching implications.
Footnotes:
- Ok, I couldn’t help myself. Let
andbe positive integers, then the connection between the greatest common divisor and least common multiple iswhereis the least common multiple. ofand↩︎.
- For example,
or↩︎.
- To the person who invented the number 0, thanks for nothing! ↩︎
- One mathematician says to the other, “Did you know that only 99.9% of people know some number theory? And luckily, I’m one of the 10% who do!” ↩︎

Leave a comment