Jumping Jiving GCD - the School of Mathematics, Applied

Jumping Jiving GCD
Summary
Resources
1
Jumping Jiving GCD
1. Motivation: Simplifying Fractions
We know that there are many different ways of writing the same number as a fraction, for
example:
2
50
=
3
75
Which means that carving out 2 thirds of a pie is the same as carving out the pie in 75 little
pieces and picking 50 of them ... hard work!
Based on this, we say that there is a β€œbest” or easiest way to write a fraction, when it is
impossible to cancel out anything between the numerator and the denominator. The
fraction is said to be reduced, or in simplest form, in this case.
To bring a fraction to its simplest form one may do successive simplifications:
50 50 ÷ 5 10 ÷ 5 2
=
=
=
75 75 ÷ 5 15 ÷ 5 3
Or one can do it in one strike like this:
50 50 ÷ 25 2
=
=
75 50 ÷ 25 3
In both cases one simplifies by numbers that divide both the numerator and denominator.
The Greatest Common Divisor (GCD) a.k.a. Highest Common Factor (HCF)
Question: What is special about the number 25 above? (think in relation to 50 and 75).
Answer: 25 is the largest natural number which divides both 50 and 75.
The greatest common divisor of two numbers is the largest number that divides them both.
The greatest common divisor of π‘Ž and 𝑏 is usually denoted by gcd(π‘Ž, 𝑏).
For example, gcd(50, 75) = 25.
Co-prime numbers
Question:
π‘Ž
Suppose that 𝑏 is the simplest form of a fraction.
What is gcd(π‘Ž, 𝑏) ?
Answer:
gcd(π‘Ž, 𝑏) = 1.
If gcd(π‘Ž, 𝑏) = 1 then π‘Ž and 𝑏 are said to be co-prime. In other words, they have no other
common divisors except 1.
Question:
Can you find a number which is co-prime with all numbers except multiples of itself?
2
Can you name all such numbers?
Answer:
The prime numbers.
Simplifying fractions, finding 𝐠𝐜𝐝(𝒂, 𝒃).
Take any two numbers π‘Ž and 𝑏. Next we’ll look at different methods for finding gcd(π‘Ž, 𝑏),
π‘Ž
that is, of bringing a fraction 𝑏 to its simplest form.
Method I: Successive simplification. Looking back at our first example
50 50 ÷ 5 10 ÷ 5 2
=
=
=
75 75 ÷ 5 15 ÷ 5 3
How can gcd(50, 75) be extracted from this calculation?
Answer:
gcd(50,75) = 25 = 5 × 5, the product of the numbers by which we simplified.
That’s because 50 ÷ 5 ÷ 5 = 50 ÷ (5 × 5) = 50 ÷ 25 = 2 and
75 ÷ 5 ÷ 5 = 75 ÷ (5 × 5) = 70 ÷ 25 = 3 and 2 and 3 clearly have no
other common divisors.
Practice exercise: Use successive simplification to find gcd(60,84).
Answer: (in its goriest form):
60 60 ÷ 2 30 ÷ 2 15 ÷ 3 5
=
=
=
=
84 84 ÷ 2 42 ÷ 2 21 ÷ 3 7
We simplified by 2, 2, and 3 so gcd(60,84) = 2 × 2 × 3 = 12.
Method II: Prime factorization.
This worked well and good, but what if we can’t easily find any common divisors?
Example: Find gcd(345, 184).
Solution: We can’t find a number that divides both 345 and 184 right away, but we can find
some divisors for each of them at a time. So let’s just prime factorize the numbers. The
hidden common factors will surely reveal themselves:
πŸ‘πŸ’πŸ“ = πŸ“ × πŸ‘ × πŸπŸ‘ and πŸπŸ–πŸ’ = πŸπŸ‘ × πŸπŸ‘.
And gcd(345,184) = 23.
Now suppose we have prime factorized two numbers. Let’s derive some basic rules for
finding their gcd.
Example: Find gcd(π‘Ž, 𝑏) for π‘Ž = 23 × 32 × 7 × 135 , and 𝑏 = 2 × 33 × 5 × 74 .
Solution: gcd(π‘Ž, 𝑏) = 2 × 32 × 7 = 126.
Rule: gcd(π‘Ž, 𝑏) = the product of all common primes, each chosen with its smallest index
between the prime factorizations of π‘Ž and 𝑏 .
Explanation: The prime 2 comes up with index 3 in π‘Ž and index 1 in 𝑏, so in gcd(π‘Ž, 𝑏) it will
come up with index 1= min( 3, 1). Recall that 2 = 21 .
3
Indeed, 2 divides both a and b but 22 wouldn’t divide b so it can’t be a factor of gcd(π‘Ž, 𝑏).
We can generalize to as many numbers we want.
Practice exercise: Find gcd(π‘Ž, 𝑏, 𝑐) when for π‘Ž = 2 × 3 × 4 × 5, and 𝑏 = 6 × 7 × 8 × 9
and for 𝑐 = 10 × 11 × 12 × 13.
Solution: Prime factorisation
Method III: Euclid’s algorithm.
What if even prime factorization fails with numbers π‘Ž and 𝑏: what if π‘Ž and 𝑏 are too large to
factorize, or what if they are written as sums with terms depending of an unknown number
𝑛?
Strategy: reduce our numbers to manageable proportions, using these simple
Simplifying principles:
π‘Ž
1) If a fraction 𝑏 can be simplified by a number, then
π‘Ž
𝑏
+ 1,
π‘Ž
𝑏
π‘Ž
π‘Ž
𝑏
π‘Ž
π‘Ž
βˆ’ 1, 𝑏 βˆ’ 2, 𝑏 βˆ’3, ... as well as
+ 2, 𝑏 + 3 ... can be simplified by the same number.
2) If a fraction
number.
π‘Ž
𝑏
can be simplified by a number, then
𝑏
π‘Ž
can be simplified by the same
Proof of the principles:
Point 2) Is pretty clear, as in both cases π‘Ž and 𝑏 are divisible by that same number.
π‘Ž
π‘Žβˆ’π‘
π‘Ž
For 1), 𝑏 βˆ’ 1 = 𝑏 . Let’s assume 𝑏 can be simplified by a number 𝑑. That is, 𝑑| π‘Ž and
𝑑|𝑏. But then 𝑑|(π‘Ž βˆ’ 𝑏). So both numerator and denominator of
We can adapt this argument for all the other fractions.
π‘Žβˆ’π‘
𝑏
are divisible by 𝑑.
Application: Euclid’s algorithm for finding gcd(π‘Ž, 𝑏), the magic simplifying factor of the
π‘Ž
fraction 𝑏 :
Let’s suppose that the fraction is what you call improper, so the denominator (bottom) is
smaller than the numerator (top). Then
1) We divide the numerator by the denominator to get a mixed number, then discard
the integer parts.
2) We turn the resulting fraction upside down, to get its reciprocal.
3) The resulting fraction will have the same simplifying factors as the original one, but
smaller numbers. We apply steps 1) and 2) again as many times as necessary until the
fraction becomes manageable.
Memo Note: Euclid’s algorithm closely resembles Greco-Roman wrestling between the
numerator and the denominator:
1) First the denominator knocks a few units off the numerator.
2) Then it topples the numerator down and gets on top.
3) They start all over again.
This analogy seems quite appropriate because Euclid founded a famous Greek school of
mathematics.
4
Example: Find gcd(π‘Ž, 𝑏) in each of the following two cases:
i) π‘Ž = 23456, and 𝑏 = 34567.
ii) π‘Ž = 6𝑛 + 10 and 𝑏 = 8𝑛 + 11 where 𝑛 is some unknown natural number.
Solutions:
i) Since 34567 > 23456, let’s start with
34567
11111
34567
:
23456
= 1 + 23456 has the same simplifying factors as
23456
23456
11111
11111
1234
1234
= 2 + 11111 has the same simplifying factors as
=9+
5
1234
has the same simplifying factors as
5
11111
23456
1234
11111
, and so also as 11111.
23456
, and so also as
11111
5
1234
.
.
1234
But 5 clearly doesn’t divide 1234 so 1234 is in reduced form, 5 and 1234 are co-prime.
34567
This means that 23456 was in reduced form in the first place, so 34567 and 23456 are coprime. In terms of gsd-s we can write:
gcd(34567,23456)=gcd(23456,11111)=gcd(11111,1234)=gcd(1234,5)=1.
ii) Solution I
π‘Ž = 6𝑛 + 10 and 𝑏 = 8𝑛 + 11 where 𝑛 is some unknown natural number.
We write 8𝑛 + 11 = 6𝑛 + 10 + 2𝑛 + 1 so
8𝑛 + 11
2𝑛 + 1
=1+
6𝑛 + 10
6𝑛 + 10
Then 6𝑛 + 10 = 3(2𝑛 + 1) + 7 so
6𝑛 + 10
7
=3+
2𝑛 + 1
2𝑛 + 1
We could even go on one more time like this:
2𝑛 + 1 = 7 + 2𝑛 βˆ’ 6 so
2𝑛 + 1
2𝑛 βˆ’ 6
=1+
7
7
Now we have two cases:
- For some values of n like 1, 2, 4, 5, 6, 7, 8, 9, 11,..., the number 2𝑛 + 6 is not
divisible by 7, so 2𝑛 βˆ’ 6 and 7 are co-prime. This makes π‘Ž and 𝑏 co-prime also.
- For other values of n like 3, 10, 17, 24, ... the number 2𝑛 βˆ’ 6 is divisible by 7, so
gcd(2𝑛 βˆ’ 6,7)= gcd(π‘Ž, 𝑏)=7. How do we recognize these values of 𝑛?
Well, because 2𝑛 βˆ’ 6 = 2(𝑛 βˆ’ 3) and 7 is a prime, so if 7| 2(𝑛 βˆ’ 3) then 7|(𝑛 βˆ’ 3),
so 𝑛 βˆ’ 3 = 7π‘˜ where π‘˜ can take the values 1,2,3,...
Solution II
We could have saved ourselves a lot of trouble if we decided to eliminate 𝑛 right away:
π‘Ž = 6𝑛 + 10 and 𝑏 = 8𝑛 + 11 .
There are 6 𝑛-s in π‘Ž and 8 𝑛-s in 𝑏). (6 and 8 are called coefficients of 𝑛).
We notice that 6 × 4 = 8 × 3 and so
4π‘Ž βˆ’ 3𝑏 = 4(6𝑛 + 10) βˆ’ 3(8𝑛 + 11) = 24𝑛 + 40 βˆ’ 24𝑛 βˆ’ 33 = 7 no more 𝑛-s!
Let’s denote gcd(π‘Ž, 𝑏) by 𝑑. Now if 𝑑|π‘Ž and 𝑑|𝑏 then 𝑑|(4π‘Ž βˆ’ 3𝑏), (prove this!)
5
so 𝑑|7 so 𝑑 can only be 7 or 1. It remains to check that either of these values can occur, like
in the first solution we used.
A surprising property of the GCD.
A flea problem
Two fleas, one red and one blue, are jumping happily along a straight line. The red flea’s
jump length is π‘Ž = 17 cm and the blue flea’s jump length is 𝑏 = 13 cm. They both start up
from the same point 0 and jump at various speeds, sometimes even stopping and waiting
for each other.
a) Find all the spots on the line where the two fleas can land in their first 5 steps, if they
jump Eastward.
b) What is the closest from each other they can ever be on their line, without having to be
both on the same spot?
c) Repeat the problem in the case when π‘Ž = 34 cm and 𝑏 = 26 cm.
d) Repeat the problem in the case when π‘Ž = 51 cm and 𝑏 = 39 cm.
boing
Solutions:
a) Since the red flea can land every 17 cm, the spots it lands on are
1 × 17 = 17,
2 × 17 = 34,
3 × 17 = 51,
4 × 17 = 68,
5 × 17 = 85.
Since the blue flea can land every 13 cm, the spots it lands on are
1 × 13 = 13,
2 × 13 = 26,
3 × 13 = 39,
4 × 13 = 52,
5 × 13 = 65.
b) From the table above we see that
4𝑏 βˆ’ 3π‘Ž = 4 × 13 βˆ’ 3 × 17 = 1,
so the fleas can get within 1 cm of each other. They cannot get any closer without bumping
into each other, because the places they land in are natural numbers and their smallest
positive difference can only be 1.
c) In the case when π‘Ž = 34 = 17 × 2 cm and 𝑏 = 26 = 13 × 2 cm, all the measures of the
landing spots above get doubled. Now 4𝑏 βˆ’ 3π‘Ž = 4 × 26 βˆ’ 3 × 34 = 2, so the fleas can
get within 2 cm of each other. They can never get any closer than that without bumping into
each other. Indeed, in this case the landing spots of the two fleas are all even, so the
distances between them will be even.
d) In the case when π‘Ž = 51 = 17 × 3 cm and 𝑏 = 39 = 13 × 3 cm, all the distances will be
multiples of 3. Now 4𝑏 βˆ’ 3π‘Ž = 4 × 39 βˆ’ 3 × 51 = 3, so the fleas can get within 3 cm of
each other, but they can never get any closer without bumping into each other.
The flea problem, mathematical formulation:
6
Let’s discuss the case when π‘Ž = 17 cm and 𝑏 = 13 cm.
Then the red fleas landing spots are all the multiples of 17 cm. The blue fleas landing spots
are all the multiples of 13 cm.
Let 𝑒 and 𝑣 be two natural numbers. Suppose that the red flea has made 𝑒 jumps and the
blue flea has made 𝑣 jumps. Let’s write an algebraic formula for the distance between the
fleas, then rewrite the conclusion of our problem b) mathematically.
The red flea has made 𝑒 jumps, it is at 𝑒 × 17 cm from the origin.
The blue flea has made 𝑣 jumps, it is at 𝑣 × 13 cm from the origin.
The distance could be either 𝑒 × 17 βˆ’ 𝑣 × 13 or βˆ’π‘’ × 17 + 𝑣 × 13 depending on
who is closest to the origin. Our problem b) proves:
1 is the smallest positive distance between any two multiples of 17 and 13.
2 is the smallest positive distance between any two multiples of 34 and 26.
1 is the smallest positive number of the form 𝑒 × 17 βˆ’ 𝑣 × 13 or βˆ’π‘’ × 17 + 𝑣 × 13,
where u and v are random natural numbers.
It’s annoying to have two formulas so let’s choose two new symbols π‘₯ and 𝑦 and set
π‘₯ = 𝑒, 𝑦 = βˆ’π‘£ if the distance is 𝑒 × 17 βˆ’ 𝑣 × 13
π‘₯ = βˆ’π‘’, 𝑦 = βˆ’π‘£ if the distance is βˆ’π‘’ × 17 + 𝑣 × 13
In either case the distance now reads 17π‘₯ + 13𝑦, but π‘₯ and 𝑦 are now random integers.
(The multiplication sign between the numbers and the symbols are implied).
1 is the smallest positive number of the form π‘₯17 + 𝑦13 where x and y are random
integers.
Question: i) What is gcd(17,13)?
ii) If rather than 17 and 13 we work with two unknown natural numbers π‘Ž and 𝑏, can you
guess how close the fleas can get from each other without being on the same spot?
Answer: i) 1; ii) 𝑑 = gcd(π‘Ž, 𝑏).
Property of the GCD:
gcd(π‘Ž, 𝑏) is the smallest positive number of the form π‘₯π‘Ž + 𝑦𝑏 where π‘₯ and 𝑦 are random
integers!
To prove this, let’s look at
A generalized flea problem
Mummy flea’s jump is π‘Ž cm long, Daddy’s jump is 𝑏 cm long, and Baby’s jump is 𝑑 cm
long. Mummy and Daddy start up from the same point and jump on a straight line at various
7
speeds. At the exact moment when Mummy and Daddy are the closest they can ever be on
their line, (but not on the same spot), Baby flea, who’s piggybacking on Daddy’s back, can
jump onto Mummy’s back, and hence on happily away.
If Mummy or Daddy take one more jump each and then wait for Baby, prove that Baby
can reach any of them if it wants to.
a) Question: How can we formulate the question mathematically in terms of π‘Ž, 𝑏 and 𝑑?
Answer: Prove that 𝑑 divides both π‘Ž and 𝑏. Let’s focus on 𝑑 divides . So we want Mummy
and Baby’s jumps to look like this:
b) Strategy: Proof by Contradiction.
We know: 𝑑 is the closest that Daddy can get to Mummy.
To prove: 𝑑 divides π‘Ž.
Idea of proof: Assume 𝑑 doesn’t divide π‘Ž.
Then Baby could only reach within π‘Ÿ cm of Mummy, where π‘Ÿ < 𝑑:
If we prove that Daddy can also get within π‘Ÿ cm of Mummy, where π‘Ÿ < 𝑑 then we
contradict the info that 𝑑 is the closest that Daddy can get to Mummy! So our assumption
was wrong: 𝑑 actually divides π‘Ž.
c) Main step:
Assuming π‘Ž = π‘˜π‘‘ + π‘Ÿ and π‘Ÿ < 𝑑, to prove that Mummy and Daddy can get within π‘Ÿ cm of
each other:
i) Let’s say that it took 1 hour for Mummy and Daddy to get within distance 𝑑 of each other.
Let’s assume they keep jumping at same speeds. How far away from each other will they be
after π‘˜ hours?
ii) Can Mummy then get within distance π‘Ÿ of Daddy?
Answers: i) π‘˜π‘‘; ii) Yes if Mummy just takes another step in the right direction: π‘Ž βˆ’ π‘˜π‘‘ = π‘Ÿ
8
d) Mathematical formulation of the proof:
We know: d is the smallest positive number of the form π‘₯π‘Ž + 𝑦𝑏 where π‘₯ and 𝑦 are
random integers.
To prove: 𝑑 divides π‘Ž.
Proof: Assume 𝑑 divides into π‘Ž with remainder r. Then π‘Ž = π‘˜π‘‘ + π‘Ÿ and π‘Ÿ < 𝑑.
But then π‘Ÿ = π‘Ž βˆ’ π‘˜π‘‘ = π‘Ž βˆ’ π‘˜(π‘₯π‘Ž + 𝑦𝑏) = π‘Ž βˆ’ π‘˜π‘₯π‘Ž βˆ’ π‘˜π‘¦π‘ = (1 βˆ’ π‘˜π‘₯)π‘Ž βˆ’ π‘˜π‘¦π‘.
...............................
............................................................................................................
Left out for lcm and co-prime purposes:
c) Are there any spots on the line, except for 0, that both fleas can reach? Can you describe
all these spots?
c) The red flea lands on multiples of 17, which we can write as 17k. The blue flea lands on
multiples of 13, which we can write as 13h. The spots where they both land have to be
multiples of both 13 and 17. The smallest would be 13 × 17 and then all multiples of that.
9