Download pdf file

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Algorithm wikipedia , lookup

Determination of the day of the week wikipedia , lookup

Fisher–Yates shuffle wikipedia , lookup

Sieve of Eratosthenes wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Euclidean algorithm wikipedia , lookup

Polynomial greatest common divisor wikipedia , lookup

Transcript
MATH 13150: Freshman Seminar
Unit 6
1. Divisibility
In this section, and the next few sections, we discuss divisibility. We will discuss some
concepts that may be familiar to you, including greatest common divisor, least common multiples, and prime numbers. Even if this is familiar to you, we will introduce
some skills which will be essential for later in the course.
1.1. Common multiples. In work related to the subtraction principle, you had to
decide that the numbers divisible by 2 and 3 are the same as the multiples of 6. You
may have noticed that 2 × 3 = 6. Let’s see what happens in another example.
QUESTION: What are the numbers divisible by 10 and 15?
Certainly, 150 = 10 × 15 is a common multiple of 10 and 15. We can try to find all
the common multiples of 10 and 15 the same way we answered the question about 2
and 3, i.e., we list the multiples of 10 and the multiples of 15 and find the common
numbers on both lists.
The multiples of 10 are:
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, ...
The multiples of 15 are:
15, 30, 45, 60, 75, 90, 105, ...
A moment’s glance reveals that the common numbers on both lists are:
30, 60, 90, ...
which are the first few multiples of 30, and in particular, 150 is not the smallest one.
From this, we can form an educated guess, or conjecture:
CONJECTURE: The common multiples of 10 and 15 are exactly the multiples of 30.
Let’s see if we can convince ourselves that this is true. We need to show two assertions:
(1) Every multiple of 30 is a multiple of 10 and a multiple of 15.
(2) A number that is not a multiple of 30 is not a common multiple of 10 and 15.
The assertion (1) is pretty easy to check. After all, if we take a multiple of 30 like
210 = 7 × 30, we can write
1
2
210 = 7 × 30 = 7 × 3 × 10 = 21 × 10, so 210 is a multiple of 10.
Similarly, 210 = 7 × 30 = 7 × 2 × 15 = 14 × 15, so 210 is a multiple of 15.
Maybe the idea is clear to you; a multiple of 30 is a multiple of 10 because 30 is a
multiple of 10, and similarly with 15 in place of 10. Just in case, note that we can
replace 7 in 7 × 30 by any number n and argue:
n × 30 = n × 3 × 10 = 3n × 10, so n × 30 is a multiple of 10.
Similarly, n × 30 = n × 2 × 15 = 2n × 15, so n × 30 is a multiple of 15.
The assertion (2) takes a little more thought. Let’s try it out in practice. 230 is a
number that is not a multiple of 30. Let’s show that it cannot be a multiple of 15.
This will look a little silly, because we can just divide, but the argument we give
will reveal something important about the nature of numbers. We need to recall a
familiar fact.
Theorem 1.1. If we divide a number d into a number n, and d goes into n q times
with remainder r, then n = q × d + r. The remainder is always less than d. Further,
d divides n evenly exactly when d divides n with remainder 0.
For example, if we divide the number 6 into the number 26, we see 6 goes into 26 4
times with remainder 2. This means 26 = 4 × 6 + 2.
It is also useful to observe the following observation:
Remark 1.2. If a number d divides two numbers m and n, then d also divides every
combination x × m + y × n, where x and y are positive or negative integers.
For example, since d = 3 divides m = 12 and n = 21, 3 also divides 2 × 12 − 5 × 21
(we take x = 2 and y = −5). It is easy to see why this works. We can write
2 × 12 − 5 × 21 = 2 × (3 × 4) − 5 × (3 × 7) = 8 × 3 − 35 × 3 = (−27) × 3.
There is nothing special about these particular numbers. They work for any choices
of d, m, n, x and y.
Now let’s try using this to see why 15 cannot divide 230. We divide 30 into 230. It
goes in 7 times with remainder 20. By Theorem ??, this means
230 = 7 × 30 + 20.
This means that we can write 20 = 230 − 7 × 30. Now, if 15 did divide 230, it would
divide 20, since 15 clearly divides 7 × 30. But 15 does not divide 20. Indeed, 10
3
divides 20, so if 15 divided 20, then 20 would be a common multiple of 10 and 15.
But we saw that 30 is the least common multiple of 10 and 15, so 15 could not have
divided 230.
Note that we can now answer the following problem.
PROBLEM: How many numbers from 201 to 2, 354 are not divisible by either 10 or
15?
To answer this, use the subtraction principle just as in unit 3 to see that:
ANSWER = (# of numbers from 201 to 2,354) MINUS (# of numbers from 201 to
2,354 divisible by 10 or 15).
But then again by the subtraction principle,
(# of numbers from 201 to 2,354 divisible by 10 or 15)
= (# of numbers from 23 to 2354 divisible by 10)
+ (# of numbers from 23 to 2354 divisible by 15)
- (# of numbers from 23 to 2354 divisible by 10 and 15).
As in Unit 3, we have to subtract the # of numbers divisible by 10 and 15, because
those would otherwise be counted twice. Note that by the earlier discussion in this
section, the numbers divisible by 10 and 15 are the same as the numbers divisible by
30, so we can count them.
The answer to the question is thus:
2154 − (216 + 143 − 72) = 1867, by using the methods of Unit 1. You should be sure
you can do this computation yourself. If you do, you should find that there are 216
multiples of 10, 143 multiples of 15, and 72 multiples of 30 in this range.
1.2. Least common multiples.
PROBLEM: For two numbers a and b, which numbers are divisible by both a and b.
To solve this, we could list the common multiples of a and b. We say that:
For two numbers a and b, the least common multiple of a and b is the least number
that is a multiple of both a and b.
For example, the least common multiple of 4 and 6 is easily computed by listing the
multiples of 4:
4
4, 8, 12, 16, 20, 24, ...
and listing the multiples of 6:
6, 12, 18, 24, ...
and seeing that 12 is the least number on both lists. This means that 12 is the least
common multiple of 4 and 6.
We write lcm(a, b) for the least common multiple of two numbers a and b, just for
convenience.
METHOD 1 FOR CALCULATING lcm(a, b):
STEP 1: List the first few multiples of a
STEP 2: List the first few multiples of b
STEP 3: Find the smallest number on both lists. That number is the least common
multiple. If there is no common element in the two lists, list more elements until
there is a common element.
Method 1 will always work, and works well for small numbers, but for bigger numbers,
it can be very time-consuming.
To solve our problem, it is reasonable to guess that the following theorem is true:
Theorem 1.3. The common multiples of two numbers a and b are exactly the multiples of the least common multiple of a and b.
For example, the common multiples of 4 and 6 are the multiples of 12. The least
common multiple of 3 and 7 is easily seen to be 21, so the common multiples of 3 and
7 are the multiples of 21.
This can be justified using an argument from the first section. That is, for any number
n, divide lcm(a, b) into n, giving
n = q ×lcm(a, b)+r, where r is either 0 or is some number between 1 and lcm(a, b)−1.
If r = 0, then this means that lcm(a, b) divides n evenly, so certainly a and b also
divide lcm(a, b), just as we argued for the Assertion (1) of the first section. On the
other hand, if r is not zero, then n cannot be a multiple of both a and b. Indeed, r
is not a multiple of both a and b because r is less than the least common multiple
of a and b. But if n is a multiple of a and b, then r = n − q × lcm(a, b) would be a
multiple of a and b, because it is a difference of two multiples of a and b (we used
Remark ?? here). This completes our argument.
1.3. Greatest common divisors. The greatest common divisor of two numbers a
and b is the greatest number that divides both a and b. We write:
5
gcd(a, b) for the greatest common divisor of a and b.
We can compute gcd(a, b) by listing all divisors of a and all divisors of b and finding
the largest number that is on both lists.
Example 1.4. Let’s compute gcd(10, 15). The divisors of 10 are 1, 2, 5, and 10.
The divisors of 15 are 1, 3, 5, and 15. The largest number on both lists is 5, so
gcd(10, 15) = 5.
Example 1.5. We compute gcd(7, 14). The divisors of 7 are 1 and 7. The divisors
of 14 are 1, 2, 7 and 14, so gcd(7, 14) = 7.
Example 1.6. We compute gcd(3, 7). The divisors of 3 are 1 and 3 and the divisors
of 7 are 1 and 7. The greatest number on both lists is 1, so 1 = gcd(3, 7).
We want to find a relation between lcm(a, b) and gcd(a, b). Let’s look at a table.
Given our present state of knowledge, computing greatest common divisors and least
common multiples is a laborious process. We’ve done a few of the calculations in this
table. You can trust me for the others.
a
4
3
10
7
12
4
b gcd(a,b) lcm(a,b)
6
2
12
7
1
21
15
5
30
14
7
14
26
2
156
10
2
20
Take a look at this table. Hopefully, you can see that in each row, the product of
the first two columns is equal to the product of the second two columns. Since the
product of the first two columns in any row is a × b and the product of the last two
columns is gcd(a, b) × lcm(a, b), this suggests the following fact:
Theorem 1.7. For any two numbers a and b,
a × b = gcd(a, b) × lcm(a, b).
Otherwise stated,
lcm(a, b) =
a×b
.
gcd(a, b)
We’ll see how to explain why this Theorem is true in a few sections, when we learn
about prime factorizations.
This theorem has a wonderful consequence. Suppose you need to know the least
common multiple of 729 and 1257. It would take quite a long time to use the method
of listing common multiples:
6
729, 1458, 2187, ...
1257, 2514, 3771, ...
and try to find the first common number on the two lists.
But suppose that someone told you that gcd(729, 1257) = 3. Then we could use the
last Theorem to quickly compute:
lcm(729, 1257) =
729 × 1257
729 × 1257
=
= 305, 451.
gcd(729, 1257)
3
At the moment, you may imagine that you need an oracle or a math genius to see
that gcd(729, 1257) = 3. In the next section, we’ll see that there is a simple way to
compute gcd(729, 1257).
1.4. How to compute greatest common divisors. Let’s think about how we
might compute gcd(a, b) for two numbers a and b. At this point, we can just say that
it is easy to do if the numbers a and b are small enough so that we know all their
divisors. From this point of view, it would be very nice to replace the computation
of gcd(a, b) with the computation of the greatest common divisor of two smaller
numbers. Let’s see how this might work in some examples.
We’ll begin with an example that you can probably do easily by listing the divisors.
PROBLEM 1: Compute gcd(25, 65).
To solve this, we’ll use the division algorithm to divide 25 into 65. We get:
65 = 2 × 25 + 15,
since 25 divides 65 twice, with remainder 15. Let’s compare
gcd(25, 65) and gcd(15, 25).
We claim that:
The common divisors of 25 and 65 are the same as the common divisors of 15 and
25.
Indeed, suppose a number d divides both 25 and 65. Then it must also divide 15 =
65 − 2 × 25 using Remark ??, so it divides 15 and 25. Similarly, if a number d divides
both 15 and 25, it must also divide 65 = 2 × 25 + 15, again using Remark ??, so d
divides 25 and 65.
Thus,
7
gcd(25, 65) = gcd(15, 25).
After all, if the common divisors of 25 and 65 are the same, and the common divisors
of 15 and 25 are the same, then the two numbers have the same greatest common
divisor.
We’ve gained something because we’ve replaced the pair of numbers 25 and 65 by the
smaller pair of numbers 15 and 25. Instead of just computing gcd(15, 25) now, it’s
better to keep trying the same method, so we now divide 15 into 25.
25 = 1 × 15 + 10
since 15 divides 25 one time, with remainder 10. Then just as before,
gcd(15, 25) = gcd(10, 15).
Now let’s again try the same method. We’ll divide 10 into 15:
15 = 1 × 10 + 5
and observe that:
gcd(10, 15) = gcd(5, 10).
Now we’re ready to complete the calculation. Since 5 divides 10 evenly, it must be
the case that gcd(5, 10) = 5. After all, 5 is a common divisor of 5 and 10, and no
bigger number can divide both.
We finally conclude that:
gcd(25, 65) = 5, since
gcd(25, 65) = gcd(15, 25) = gcd(10, 15) = gcd(5, 10) = 5.
Let’s record a couple of facts that we’ve used in the course of this argument.
Remark 1.8. (1) Suppose b = q × a + r. Then gcd(a, b) = gcd(r, a).
(2) If a number a divides a number b evenly, then gcd(a, b) = a.
Although this looks like a really long, absurdly complicated way to see that gcd(25, 65) =
5, the point is that it always works, for any two numbers. Let’s try this method in
another example.
PROBLEM: Compute gcd(42, 322).
8
STEP 1: Divide 42 into 322. It goes in 7 times with remainder 28, so
322 = 7 × 42 + 28.
STEP 2: Using (1) from Remark ?? above, we get:
gcd(42, 322) = gcd(28, 42).
Now we go back and apply STEP 1 to 28 and 42.
STEP 1 (2nd cycle): Divide 28 into 42. We get:
42 = 1 × 28 + 14.
STEP 2 (2nd cycle): Again using (1) from Remark ?? above, we get:
gcd(28, 42) = gcd(14, 28).
Now we apply STEP 1 to 14 and 28.
STEP 1 (3rd cycle): Divide 14 into 28. We get:
28 = 2 × 14, i.e., 14 divides 28 evenly.
Then we conclude:
STEP 2 (3rd cycle): Since 14 divides 28 evenly, gcd(14, 28) = 14. Now we’re done,
since
gcd(42, 322) = gcd(28, 42) = gcd(14, 28) = 14, so gcd(42, 322) = 14.
We’ve answered our question. Even though we may not be able to easily see that 14
is the greatest number dividing both 42 and 322, we know that each of our steps is
solid, so we must be correct.
The point we’re getting at here is that for any two numbers a and b, we can compute
gcd(a, b) by following these steps. Let’s pause for a moment to record the steps. The
series of steps is called the Euclidean algorithm.
EUCLIDEAN ALGORITHM for computing gcd(a, b), for two numbers a and b, with
a less than b.
STEP 1: Divide a into b to write b = q × a + r.
STEP 2: If r = 0, then gcd(a, b) = a, and we’re done.
9
If r 6= 0, then gcd(a, b) = gcd(r, a). Go back and do STEP 1 with (r, a) in place of
(a, b).
Because r is always smaller than a, the numbers involved will always get smaller, and
eventually r will be 0, and we’ll be able to stop.
Let’s do a few more examples, in part to give you the idea that once you get the hang
of it, this is pretty easy to do.
PROBLEM: Compute gcd(18, 44).
Divide 18 into 44. We get
44 = 2 × 18 + 8.
Since the remainder r = 8 is not 0, replace (18, 44) with (8, 18) and repeat.
Divide 8 into 18 to get:
18 = 2 × 8 + 2.
Since the remainder 2 is not 0, replace (8, 18) with (2, 8) and repeat.
Divide 2 into 8 go get:
8 = 4 × 2 + 0.
Since the remainder r = 0, we get gcd(2, 8) = 2, so gcd(18, 44) = gcd(8, 18) =
gcd(2, 8) = 2.
We can express all this by writing the steps in a compact version as:
44 = 2 × 18 + 8
18 = 2 × 8 + 2
8=4×2+0
so gcd(18, 44) = gcd(8, 18) = gcd(2, 8) = 2, so the answer is gcd(18, 44) = 2.
PROBLEM: Compute gcd(729, 1257).
This will take awhile, so we’ll just write the compact version. You may need a
calculator to work out the division steps:
1257 = 1 × 729 + 528
729 = 1 × 528 + 201
528 = 2 × 201 + 126
201 = 1 × 126 + 75
126 = 1 × 75 + 51
75 = 1 × 51 + 24
10
51 = 2 × 24 + 3
24 = 8 × 3 + 0.
Since the last remainder is 0, gcd(729, 1257) = 3. That’s the final answer. Another
way of saying this is the greatest common divisor is the last nonzero remainder in the
table.
METHOD 2 for calculating lcm(a, b):
STEP 1: Compute gcd(a, b) (usually using the Euclidean algorithm)
a×b
STEP 2: Then lcm(a, b) =
.
gcd(a, b)
To do this, we first compute gcd(33, 50).
Here is the compact version of the calculation:
50 = 1 × 33 + 17
33 = 1 × 17 + 16
17 = 1 × 16 + 1
16 = 16 × 1 + 0
so gcd(33, 50) = 1. Then we can use the relation between lcm and gcd to conclude
33 × 50
lcm(33, 50) =
= 1650.
1
PROBLEM: How many numbers from 323 to 4457 are multiples of 33 or 50?
33 × 50
=
To solve this problem we note that since gcd(33, 50) = 1, lcm(33, 50) =
1
1650 using Theorem ??. It follows that the common multiples of 33 and 50 are the
common multiples of 1650.
We then compute:
# of multiples of 33 from 323 to 4457 is 126
# of multiples of 50 from 323 to 4457 is 83
# of multiples of 1650 from 323 to 4457 is 2
The answer to this problem is thus,
126 + 83 − 2 = 207.
1.5. Comments : This procedure where the same steps are repeated over and over
again is called an algorithm. An algorithm is just a definite procedure to solve a
problem. If you ever learn to write computer programs, you’ll become very familiar
with algorithms.
11
Although carrying out an algorithm can seem boring (and this is why we usually let
computers do them), being able to do them precisely and carefully is an important
part of doing mathematics. In the next chapter, we’ll meet another algorithm which
solves an even more important problem.
EXERCISES: Explain your answer.
(1) Find the following least common multiples by using the simple method, i.e.,
list the first few multiples of each number:
(a) lcm(2, 6)
(b) lcm(6, 9)
(c) lcm(12, 30)
(d) lcm(5, 6)
(e) lcm(12, 12)
(2) If a is any number, what is lcm(a, a)? What is gcd(a, a)? Explain your answer.
(3) How many numbers are there from 75 to 586 that are divisible by 12 or 30?
(4) Find the following greatest common divisors (I strongly recommend that you
use the Euclidean algorithm so you get used to using it):
(a) gcd(30, 64)
(b) gcd(111, 144)
(c) gcd(111, 211)
(d) gcd(651, 6363)
(e) gcd(104, 273)
(f) gcd(10, 10)
(5) Find the following least common multiplies (hint: use the results of the previous problem):
(a) lcm(30, 64)
(b) lcm(111, 144)
(c) lcm(111, 211)
(d) lcm(651, 6363)
(e) lcm(10, 10)
(6) (a) How many numbers from 200 to 31, 112 are divisible by 111 or 144?
(b) How many numbers from 200 to 31, 112 are not divisible by 111 or 144?