Вы находитесь на странице: 1из 3

Massachusetts Institute of Technology

6.042J/18.062J, Spring ’18: Mathematics for Computer Science April 20


Dr. Zachary Abel revised Friday 13th April, 2018, 19:27

Solutions to Problem Set 6

Reading: Chapter 9 through 9.10: GCDs, Congruences, and Euler’s Theorem

Problem 1.
Here is a game you can analyze with number theory and always beat me. We start with two distinct, positive
integers written on a blackboard. Call them a and b. Now we take turns. (I’ll let you decide who goes first.)
On each turn, the player must write a new positive integer on the board that is the difference of two numbers
that are already there. If a player cannot play, then they lose.
For example, suppose that 12 and 15 are on the board initially. Your first play must be 3, which is 15 12.
Then I might play 9, which is 12 3. Then you might play 6, which is 15 9. Then I can’t play, so I lose.
(a) Show that every number on the board at the end of the game is a multiple of gcd.a; b/.

Solution. Thinking of the game as a state machine, we observe that the property that gcd.a; b/ divides
all the numbers on the board is an invariant. This follows because the next state (board) is the same as
the previous state, except for an additional number which is the difference of two numbers already there.
Assuming these two numbers are divisible by gcd.a; b/, we know that their difference will be as well, which
proves that the next state satisfies the invariant.


(b) Show that every positive multiple of gcd.a; b/ up to max.a; b/ is on the board at the end of the game.

Solution. Assume without loss of generality that a > b. Let s be the smallest number on the board at the
end of the game. So a D qs C r where 0  r < s by the division algorithm. Then a s must be on the
board and thus so must a 2s, a 3s, . . . , a .q 1/s. However, r D a qs cannot be on the board, since
r < s and s is defined to be the smallest number there. The only explanation is that r D 0, which implies
that s j a. By the same argument, s j b. Therefore, s is a common divisor of a and b. Since s is a multiple
of the greatest common divisor of a and b by the preceding problem part, s must actually be the greatest
common divisor. We already argued that a, a s, a 2s, . . . , a .q 1/s must be on the board, and these
are all the positive multiples of gcd.a; b/ up to max.a; b/.


(c) Describe a strategy that lets you win this game every time.

Solution. Assume without loss of generality that a  b. By the previous parts, the numbers that appear on
the final board are precisely all the multiples  a of gcd.a; b/. Thus, for each game, we know exactly how
many values will be placed on the board before the game ends. So if an odd number of values will appear
on the final board (which happens precisely when a is an even multiple of gcd.a; b/), then choose to go
first. 

2018, Albert R Meyer. This work is available under the terms of the Creative Commons Attribution-ShareAlike 3.0
license.
2 Solutions to Problem Set 6

Problem 2.
Two nonparallel lines in the real plane intersect at a point. Algebraically, this means that the equations

y D m1 x C b1
y D m2 x C b2

have a unique solution .x; y/, provided m1 ¤ m2 . This statement would be false if we restricted x and y to
the integers, since the two lines could cross at a noninteger point:

However, an analogous statement holds if we work over the integers modulo a prime p. Find a solution
to the congruences

y  m1 x C b1 .mod p/
y  m2 x C b2 .mod p/

when m1 6 m2 .mod p/. Express your solution in the form x ‹ .mod p/ and y ‹ .mod p/ where the
‹’s denote expressions involving m1 , m2 , b1 and b2 . You may find it helpful to solve the original equations
over the reals first.

Solution. Subtracting the second congruence from the first, we have:

0  m1 x C b1 .m2 x C b2 / .mod p/
.m1 m2 /x  b2 b1 .mod p/
1
x  .m1 m2 /  .b2 b1 / .mod p/

Substituting this value of x into the first congruence, we have


1
y  m1  .m1 m2 /  .b2 b1 / C b1 .mod p/

Here .m1 m2 / 1 .mod p/ exists because m1 6 m2 .mod p/, and hence p does not divide .m1 m2 /.
Further exercise: Show that .x; y/ are unique modulo p.


Problem 3.
In this problem we’ll prove that for all integers a; m where m > 1,

am  am .m/
.mod m/: (1)

Note that a and m need not be relatively prime.


Assume m D p1k1    pnkn for distinct primes, p1 ; : : : ; pn and positive integers k1 ; : : : ; kn .
Solutions to Problem Set 6 3

(a) Show that if pi does not divide a, then

a.m/  1 .mod piki /:

Solution.
ki ki
a.m/ D a.pi /.m=pi /
 .m=pki /
k i
.pi i /
D a
ki
 1.m=pi /
.mod piki / (Euler’s Theorem, since gcd.a; pi / D 1)
D 1;

(b) Show that if pi j a then


am .m/
0 .mod piki /: (2)

Solution. Since pi j a, we have piki j aki . That is

a ki  0 .mod piki /;

and hence
an  0 .mod piki /
for any n  ki . So we need only show that m .m/  ki . But m .m/ is the number of integers in
Œ0; m/ that are not relatively prime to m, and there are at least ki of them, namely, 0; pi ; pi2 ; : : : ; piki 1 . 

(c) Conclude (1) from the facts above.


Hint: am am .m/ D am .m/ .a.m/ 1/.

Solution. Let b WWD am am .m/ . So (1) holds iff b  0 .mod m/. But using the hint that b D cd where
c WWD am .m/ and d WWD a.m/ 1, we have from part (a) that

c0 .mod piki /; if pi does not divide a, and


d 0 .mod piki /; if pi j a;

so in any case,
b D cd  0 .mod piki / for 1  i  n:

This implies that b  0 modulo the product p1k1    pnkn , namely

b0 .mod m/ :

Вам также может понравиться