Problem Solving and Recreational Mathematics
Paul Yiu
Department of Mathematics Florida Atlantic University
Summer 2012
Chapters 1–44
August 1
Monday 6/25 7/2 7/9 7/16 7/23 7/30 Wednesday 6/27 *** 7/11 7/18 7/25 8/1 Friday 6/29 7/6 7/13 7/20 7/27 8/3 ii Contents
1 Digit problems 101 1.1 When can you cancel illegitimately and yet get the cor- rectanswer? ...... 101 1.2 Repdigits...... 103 1.3 Sortednumberswithsortedsquares ...... 105 1.4 Sumsofsquaresofdigits ...... 108
2 Transferrable numbers 111 2.1 Right-transferrablenumbers ...... 111 2.2 Left-transferrableintegers ...... 113
3 Arithmetic problems 117 3.1 AnumbergameofLewisCarroll ...... 117 3.2 Reconstruction of multiplicationsand divisions . . . . . 120 3.2.1 Amultiplicationproblem...... 120 3.2.2 Adivisionproblem ...... 121
4 Fibonacci numbers 201 4.1 TheFibonaccisequence ...... 201 4.2 SomerelationsofFibonaccinumbers ...... 204 4.3 Fibonaccinumbersandbinomialcoefficients ...... 205
5 Counting with Fibonacci numbers 207 5.1 Squaresanddominos ...... 207 5.2 Fatsubsetsof [n] ...... 208 5.3 Anarrangementofpennies ...... 209
6 Fibonacci numbers 3 211 6.1 FactorizationofFibonaccinumbers ...... 211 iv CONTENTS
6.2 TheLucasnumbers ...... 214 6.3 Countingcircularpermutations ...... 215
7 Subtraction games 301 7.1 TheBachetgame ...... 301 7.2 TheSprague-Grundysequence ...... 302 7.3 Subtraction of powers of 2 ...... 303 7.4 Subtractionofsquarenumbers ...... 304 7.5 Moredifficultgames...... 305
8 The games of Euclid and Wythoff 307 8.1 ThegameofEuclid ...... 307 8.2 Wythoff’sgame ...... 309 8.3 Beatty’sTheorem ...... 311
9 Extrapolation problems 313 9.1 Whatis f(n + 1) if f(k)=2k for k =0, 1, 2 ...,n? . . 313 1 9.2 Whatis f(n + 1) if f(k)= k+1 for k =0, 1, 2 ...,n? . 315 9.3 Whyis ex notarationalfunction? ...... 317
10 The Josephus problem and its generalization 401 10.1 TheJosephusproblem ...... 401 10.2 Chamberlain’ssolution ...... 403 10.3 The generalized Josephus problem J(n, k) ...... 404
11 The nim game 407 11.1 Thenimsum...... 407 11.2 Thenimgame ...... 408
12 Prime and perfect numbers 411 12.1 Infinitudeofprimenumbers ...... 411 12.1.1 Euclid’sproof...... 411 12.1.2 Fermatnumbers ...... 411 12.2 ThesieveofEratosthenes ...... 412 12.2.1 A visualization of the sieveof Eratosthenes . . . 412 12.3 Theprimenumbersbelow20000 ...... 414 12.4 Perfectnumbers ...... 415 12.5 Mersenneprimes...... 416 12.6 CharlesTwiggonthefirst10perfectnumbers . . . . . 417 12.7 Primesinarithmeticprogression ...... 421 CONTENTS v
12.8 Theprimenumberspirals ...... 421 12.8.1 The prime number spiral beginningwith 17 . . . 422 12.8.2 The prime number spiral beginningwith 41 . . . 423
13 Cheney’s card trick 501 13.1 Threebasicprinciples ...... 501 13.1.1 Thepigeonholeprinciple ...... 501 13.1.2 Arithmetic modulo 13 ...... 501 13.1.3 Permutationsofthreeobjects...... 502 13.2 Examples...... 503
14 Variations of Cheney’s card trick 505 14.1 Cheney card trick with spectator choosing secret card . 505 14.2 A 3-cardtrick ...... 507
15 The Catalan numbers 511 15.1 Numberofnonassociativeproducts ...... 511
16 The golden ratio 601 16.1 Divisionofasegmentinthegoldenratio ...... 601 16.2 Theregularpentagon ...... 603 16.3 Construction of 36◦, 54◦, and 72◦ angles ...... 604 16.4 Themostnon-isoscelestriangle ...... 608
17 Medians and angle Bisectors 609 17.1 Apollonius’Theorem ...... 609 17.2 Anglebisectortheorem ...... 611 17.3 Theanglebisectors ...... 612 17.4 Steiner-LehmusTheorem ...... 613
18 Dissections 615 18.1 Dissection of the 6 6 square...... 615 × 18.2 Dissectionof a 7 7 squareintorectangles...... 617 18.3 Dissectarectangletoformasquare× ...... 619 18.4 Dissectionofasquareintothreesimilarparts ...... 620
19 Pythagorean triangles 701 19.1 PrimitivePythagoreantriples ...... 701 19.1.1 Rationalangles ...... 702 vi CONTENTS
19.1.2 Some basic properties of primitive Pythagorean triples...... 702 19.2 A Pythagorean trianglewithan inscribedsquare . . . . 704 19.3 When are x2 px q bothfactorable? ...... 705 19.4 Dissection of− a square± into Pythagorean triangles . . . . 705
20 Integer triangles with a 60◦ or 120◦ angle 707 20.1 Integer triangles with a 60◦ angle ...... 707 20.2 Integer triangles with a 120◦ angle ...... 710
21 Triangles with centroid on incircle 713 21.1 Construction ...... 714 21.2 Integertriangleswithcentroidontheincircle ...... 715
22 The area of a triangle 801 22.1 Heron’sformulafortheareaofatriangle ...... 801 22.2 Herontriangles...... 803 22.2.1 TheperimeterofaHerontriangleiseven . . . . 803 22.2.2 The area of a Heron triangle is divisible by 6 . . 803 22.2.3 Heron triangles with sides < 100 ...... 804 22.3 Heron triangles with sides in arithmetic progression . . 805 22.4 IndecomposableHerontriangles ...... 807 22.5 Herontriangleaslatticetriangle...... 809
23 Heron triangles 811 23.1 Herontriangleswithareaequaltoperimeter ...... 811 23.2 Herontriangleswithintegerinradii ...... 812 23.3 Division of a triangle into two subtriangles with equal incircles ...... 813 23.4 Inradiiinarithmeticprogression...... 817 23.5 Herontriangleswithintegermedians ...... 818 23.6 Herontriangleswithsquareareas ...... 819
24 TriangleswithsidesandonealtitudeinA.P. 821 24.1 Newton’ssolution ...... 821 24.2 Thegeneralcase ...... 822
25 The Pell Equation 901 25.1 The equation x2 dy2 =1 ...... 901 25.2 The equation x2 − dy2 = 1 ...... 903 − − CONTENTS vii
25.3 The equation x2 dy2 = c ...... 903 − 26 Figurate numbers 907 26.1 Whichtriangularnumbersaresquares?...... 907 26.2 Pentagonalnumbers ...... 909 26.3 Almostsquaretriangularnumbers...... 911 26.3.1 Excessivesquaretriangularnumbers ...... 911 26.3.2 Deficientsquaretriangularnumbers ...... 912
27 Special integer triangles 915 27.1 AlmostisoscelesPythagoreantriangles ...... 915 27.1.1 The generators of the almost isosceles Pythagorean triangles...... 916
27.2 Integer triangles (a, a +1, b) with a 120◦ angle . . . . . 917
28 Heron triangles 1001 28.1 Herontriangleswithconsecutivesides ...... 1001 28.2 Heron triangles with two consecutivesquare sides . . . 1002
29 Squares as sums of consecutive squares 1005 29.1 Sumofsquaresofnaturalnumbers ...... 1005 29.2 Sumsofconsecutivesquares: oddnumbercase . . . . . 1008 29.3 Sumsofconsecutivesquares: evennumbercase . . . . 1010 29.4 Sumsofpowersofconsecutiveintegers ...... 1012
30 Lucas’ problem 1013 30.1 Solution of n(n + 1)(2n +1)=6m2 for even n . . . . 1013 30.2 The Pell equation x2 3y2 =1 revisited ...... 1014 − 30.3 Solution of n(n + 1)(2n +1)=6m2 for odd n . . . . .1015
31 Some geometry problems 1101
32 Basic geometric constructions 1109 32.1 Somebasicconstructionprinciples ...... 1109 32.2 Geometricmean ...... 1110 32.3 Harmonicmean ...... 1111 32.4 A.M G.M. H.M...... 1112 ≥ ≥ viii CONTENTS
33 Construction of a triangle from three given points 1115 33.1 Someexamples ...... 1115 33.2 Wernick’sconstructionproblems ...... 1117
34 The classical triangle centers 1201 34.1 Thecentroid ...... 1201 34.2 Thecircumcircleandthecircumcenter ...... 1202 34.3 Theincenterandtheincircle ...... 1203 34.4 TheorthocenterandtheEulerline...... 1204 34.5 Theexcentersandtheexcircles ...... 1205
35 The nine-point circle 1207 35.1 Thenine-pointcircle...... 1207 35.2 Feuerbach’stheorem...... 1208 35.3 Lewis Carroll’s unused geometry pillowproblem . . . . 1209 35.4 Johnson’stheorem ...... 1211 35.5 Triangles with nine-point center on the circumcircle . . 1212
36 The excircles 1213 36.1 Arelationamongtheradii ...... 1213 36.2 Thecircumcircleoftheexcentraltriangle ...... 1214 36.3 Theradicalcircleoftheexcircles ...... 1215 36.4 Apollonius circle: the circular hull of the excircles . . . 1216 36.5 Three mutually orthogonal circles with given centers . . 1217
37 The Arbelos 1301 37.1 Archimedes’twincircletheorem ...... 1301 37.2 Incircleofthearbelos ...... 1302 37.2.1 Constructionofincircleofarbelos ...... 1304 37.3 Archimedeancirclesinthearbelos ...... 1304 37.4 Constructionsoftheincircle...... 1307
38 Menelaus and Ceva theorems 1309 38.1 Menelaus’theorem ...... 1309 38.2 Ceva’stheorem...... 1311
39 Routh and Ceva theorems 1317 39.1 Barycentriccoordinates ...... 1317 39.2 Cevianandtraces ...... 1318 39.3 Areaandbarycentriccoordinates ...... 1320 CONTENTS ix
40 Elliptic curves 1401 40.1 AproblemfromDiophantus...... 1401 40.2 Dudeney’spuzzleofthedoctorofphysic ...... 1403 40.3 Grouplawon y2 = x3 + ax2 + bx + c ...... 1404
41 Applications of elliptic curves to geometry problems 1407 41.1 Pairs of isoscelestriangleand rectanglewithequal perime- tersandequalareas ...... 1407 41.2 Triangles with a median, an altitude, and an angle bi- sectorconcurrent...... 1409
42 Integer triangles with an altitude equal to a bisector 1411 42.1 Aquarticequation ...... 1411 42.2 Transformation of a quartic equation into an elliptic curve1413
43 The equilateral lattice L (n) 1501 43.1 Countingtriangles ...... 1501 43.2 Countingparallelograms...... 1504 43.3 Countingregularhexagons ...... 1505
44 Counting triangles 1509 44.1 Integer triangles of sidelengths n ...... 1509 44.2 Integer scalene triangles with sidelengths≤ n . . . . .1510 44.3 Number of integer triangles with perimeter≤n ...... 1511 44.3.1 The partition number p3(n) ...... 1511
Chapter 1
Digit problems
1.1 When can you cancel illegitimately and yet get the correct answer?
Let ab and bc be 2-digit numbers. When do such illegitimate cancella- tions as
ab ab a bc = bc6 = c , 6 a allowing perhaps further simplifications of c ? 16 1 19 1 26 2 49 4 Answer. 64 = 4 , 95 = 5 , 65 = 5 , 98 = 8 . Solution. We may assume a, b, c not all equal. 10a+b a Suppose a, b, c are positive integers 9 such that 10b+c = c . (10a + b)c = a(10b + c), or (9a + b≤)c = 10ab. If any two of a, b, c are equal, then all three are equal. We shall therefore assume a, b, c all distinct. 9ac = b(10a c). If b is not divisible− by 3, then 9 divides 10a c = 9a +(a c). It follows that a = c, a case we need not consider. − − It remains to consider b =3, 6, 9. Rewriting (*) as (9a + b)c = 10ab. If c is divisible by 5, it must be 5, and we have 9a + b = 2ab. The only possibilities are (b, a)=(6, 2), (9, 1), giving distinct
(a, b, c)=(1, 9, 5), (2, 6, 5). 102 Digit problems
If c is not divisible by 5, then 9a + b is divisible by 5. The only possibilities of distinct (a, b) are (b, a) = (3, 8), (6, 1), (9, 4). Only the latter two yield (a, b, c)=(1, 6, 4), (4, 9, 8).
Exercise 1. Find all possibilities of illegitimate cancellations of each of the fol- lowing types, leading to correct results, allowing perhaps further simplifications.
abc c (a) b6 ad6 = d , 6 6 cab c (b) d6ba6 = d , 6 6 abc a (c) bcd6 6 = d . 6 6 2. Find all 4-digit numbers like 1805 = 192 5, which, when divided by the its last two digits, gives the square× of the number one more than its first two digits. 1.2 Repdigits 103
1.2 Repdigits
A repdigit is a number whose decimal representation consists of a rep- etition of the same decimal digit. Let a be an integer between 0 and 9. For a positive integer n, the repdigit an consists of a string of n digits each equal to a. Thus, a a = (10n 1). n 9 −
Exercise 1. Show that 16 1 19 1 26 2 49 4 n = , n = , n = , n = . 6n4 4 9n5 5 6n5 5 9n8 8
Solution. More generally, we seek equalities of the form abn = a for bnc c distinct integer digits a, b, c. Here, abn is digit a followed by n digits each equal to b. To avoid confusion, we shall indicate multiplication with the sign . The condition× (ab ) c =(b c) a is equivalent to n × n × b 10b 10na + (10n 1) c = (10n 1)+ c a, 9 − 9 − b 10b (10n 1)a + (10n 1) c = (10n 1) a. − 9 − 9 − 10n 1 Cancelling a common divisor 9− , we obtain (9a + b)c = 10ab, which ab a is the same condition for bc = c . 104 Digit problems
Exercise 1. Prove that for 1 a, b 9, a b = b a . ≤ ≤ × n × n 2. Complete the following multiplication table of repdigits.
1n 2n 3n 4n 5n 6n 7n 8n 9n 1 1n 2n 3n 4n 5n 6n 7n 8n 9n 2 4n 6n 8n 1n0 13n 12 15n 14 17n 16 19n 18 − − − − 3 9n 13n 12 16n 15 19n 18 23n 11 26n 14 29n 17 − − − − − − 4 17n 16 2n0 26n 14 31n 208 35n 12 39n 16 − − − − − 5 27n 15 3n0 38n 15 4n0 49n 15 − − − 6 39n 16 46n 12 53n 228 59n 14 − − − − 7 54n 239 62n 216 69n 13 − − − 8 71n 204 79n 12 − − 9 98n 201 −
3. Verify 26n = 2 . 6n5 5 Solution. It isenoughto verify 5 (26 )=2 (6 5). × n × n
5 (26 )= 5(20 +6 )=10 +3 0=13 0; × n n n n+1 n n 2 (6n5)= 2(6n0+5)=13n 120+10=13n0. × −
4. Simplify (1n)(10n 15). − Answer. (1n)(10n 15)=1n5n. − 1.3Sortednumberswithsortedsquares 105
1.3 Sorted numbers with sorted squares
A number is sorted if its digits are nondecreasing from left to right. It is strongly sorted if its square is also sorted. It is known that the only strongly sorted integers are given in the table below. 1 1, 2, 3, 6, 12, 13, 15, 16, 38, 116, 117. • 16 7. • n 3 4. • n 3 5. • n 3 6 7. • m n
(3 5 )2 =(10 3 + 5)2 n 1 · n =100 (3 )2 + 100 (3 )+25 · n · n =1n 108n 19102 +3n25 − − =1n 112n 1225 − − =1n2n+15.
If x =3m6n7, then 3x = 10m 110n1, and it is easy to find its square. −
2 1m3m4n m+16m8n9, if n +1 m, (3m6n7) = − ≥ 1m3n+15m n 16n+18n9, if n +1 < m. ( − −
More generally, the product of any two numbers of the form 3m6n7 is sorted.
1Problem 1234, Math. Mag., 59 (1986) 1, solution, 60 (1987)1. See also R. Blecksmith and C. Nicol, Monotonic numbers, Math. Mag., 66 (1993) 257–262. 106 Digit problems
Exercise
1. Find all natural numbers whose square (in base 10) is represented by odd digits only.
2. Find the three 3-digit numbers each of which is equal to the product of the sum of its digits by the sum of the squares of its digits. Answer. 133, 315, 803.
3. Find all 4-digit numbers abcd such that √3 abcd = a + b + c + d. Answer. 4913 and 5832. Solution. There are only twelve 4-digit numbers which are cubes. For only two of them is the cube root equal to the sum of digits.
n 10 11 12 13 14 17 16 17 18 19 20 21 n3 1000 1331 1728 2197 2744 3375 4096 4913 5832 6859 8000 9261 ∗∗∗ ∗∗∗
4. Use each digit 1, 2, 3, 4, 5, 6, 7, 8, 9 exactly once to form prime numbers whose sum is smallest possible. What if we also include the digit 0?
5. There are exactly four 3-digit numbers each equal to the sum of the cubes of its own digits. Three of them are 153, 371, and 407. What is the remaining one?
6. Find all possibilities of a 3-digit number such that the three num- bers obtained by cyclic permutations of its digits are in arithmetic progression. Answer. 148, 185, 259, 296. Solution. Let abc be one such 3-digit numbers, with a smallest among the digits (which are not all equal). The other two numbers are bca and cab. Their sum abc + bca + cab = 111 (a + b + c). Therefore the middle number = 37 (a + b + c). × × We need therefore look for numbers of the form abc = 37 k with digit sum equal to s, and check if 37 s = bca or cab.× We may ignore multiples of 3 for k (giving repdigits× for 37 k). Note that 3k < 27. We need only consider k =4, 5, 7, 8. × 1.3Sortednumberswithsortedsquares 107
k 37 k s 37 s arithmetic progression 4 148× 13 13 37=481× 148, 481, 814 5 185 14 14 × 37=518 185, 518, 851 7 259 16 16 × 37=592 259, 592, 925 8 296 17 17 × 37=629 296, 629, 962 ×
7. A 10-digit number is called pandigital if it contains each of the dig- its 0, 1,..., 9 exactly once. For example, 5643907128 is pandigi- tal. We regard a 9-digit number containing each of 1,..., 9 exactly once as pandigital (with 0 as the leftmost digit). In particular, the number A := 123456789 is pandigital. There are exactly 33 positive integers n for which nA are pandigital as shown below.
n nA n nA n nA 1 123456789 2 246913578 4 493827156 5 617283945 7 864197523 8 987654312 10 1234567890 11 1358024679 13 1604938257 14 1728395046 16 1975308624 17 2098765413 20 2469135780 22 2716049358 23 2839506147 25 3086419725 26 3209876514 31 3827160459 32 3950617248 34 4197530826 35 4320987615 40 4938271560 41 5061728349 43 5308641927 44 5432098716 50 6172839450 52 6419753028 53 6543209817 61 7530864129 62 7654320918 70 8641975230 71 8765432019 80 9876543120
How would you characterize these values of n? 8. Find the smallest natural number N, such that, in the decimal nota- tion, N and 2N together use all the ten digits 0, 1,..., 9. Answer. N = 13485 and 2N = 26970. 108 Digit problems
1.4 Sums of squares of digits
Given a number N = a1a2 an of n decimal digits, consider the “sum of digits” function ···
s(N)= a2 + a2 + + a2 . 1 2 ··· n For example
s(11) = 2, s(56) = 41, s(85) = 89, s(99) = 162.
For a positive integer N, consider the sequence
S(N) : N, s(N), s2(N), ...,sk(N), ...,
where sk(N) is obtained from N by k applications of s. Theorem 1.1. For every positive integer N, the sequence S(N) is either eventually constant at or periodic. The period has length 8 and form a cycle
Exercise
n 1 1. Prove by mathematical induction that 10 − > 81n for n 4. ≥ Solution. Clearly this is true for n =4: 103 > 81 4. n 1 · Assume 10 − > 81n. Then
n n 1 10 = 10 10 − > 10 81n> 81(n + 1). · · n 1 Therefore, 10 − > 81n for n 4. ≥ 1.4 Sums of squares of digits 109
2. Prove that if N has 4 or more digits, then s(N) < N. Solution. If N has n digits, then n 1 (i) N 10 − , (ii) s(N≥) 81n. ≤ n 1 From the previous exercise, for n 4, N 10 − > 81n s(N). ≥ ≥ ≥ 3. Verify a stronger result: if N has 3 digits, then s(N) < N. Solution. We seek all 3-digit numbers N = abc for which s(N) N. ≥ (i) Since s(N) 243, we need only consider n 243. ≤ ≤ (ii) Now if a =2, then s(N)=4+ b2 + c2 186 < N. Therefore a =1. ≤ (iii) s(N)=12 +b2 +c2 is a 3-digit number if and only if b2 +c2 99. Here are the only possibilities: ≥
(b, c) (5, 9) (6, 9) (7, 9) (8, 9) (9, 9) (6, 8) (7, 8) (8, 8) (9, 5) (9, 6) (9, 7) (9, 8) (8, 6) (8, 7) s(N) 107 118 131 146 183 101 114 129
Therefore there is no 3-digit number N satisfying s(N) N. ≥ 4. For a given integer N, there is k for which sk(N) is a 2-digit num- ber. 5. If n is one of the integers 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, then sk(N)=1 for some k.
7 70
44 94 19 91
49 23 79 82 32 28 97 31 86
13 130 68
10 100
1 110 Digit problems
6. If N is a 2-digit integer other than 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, then the sequence S(N) is eventually cycling between 4, 16, 37, 58, 89, 145, 42, 20.
60 6
63
36
66 54
45
84 48 22 27 14
72 41
35 71
80 8 53 17
46 43 5
64 34 50
52 25
29
67 76 92 3 77 83
85 9 30 98 38 81 73 89 56 39 145 58 61 90 47 65 93
42 37 33 95 18 57
20 16 106 74 75 4 59 40 24 62
2 26
11 51
113 117
69 78 87
128
88 Chapter 2
Transferrable numbers
2.1 Right-transferrable numbers
A positive integer is right-transferrable if in moving its leftmost digit to the rightmost position results in a multiple of the number. Suppose a right-transferrable number X has n digits, with leftmost digit a. We have
n 1 10(X a 10 − )+ a = kX − · for some integer k satisfying 1 k 9. From this, ≤ ≤ (10 k)X = a(10n 1)=9 a , − − × n and 9 a 1 X = × × n . 10 k −
Clearly, k =1 if and only if X = an, a repdigit. We shall henceforth assume k > 1. Since X is an n-digit number, we must have a< 10 k. Most of the combinations of (a, k) are quickly eliminated. In the table− below, N indicates that X is not an integer, and R indicates that X is a repdigit (so that k cannot be greater than 1). 112 Transferrable numbers
k a 1 2 3 4 5 6 7 8 9 2\ N N N N N N N 3 ∗ ∗ 4 N R N R N ∗ ∗ ∗ 5 N N N N ∗ ∗ ∗ ∗ 6 N N N ∗ ∗ ∗ ∗ ∗ 7 R R ∗ ∗ ∗ ∗ ∗ ∗ 8 N ∗ ∗ ∗ ∗ ∗ ∗ ∗ 9 ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ This table shows that k must be equal to 3, and a(10n 1) X = − . 7 Since a < 7, we must have 7 dividing 10n 1. This is possible only if 106m−1 n is a multiple of 6. Therefore X = a 7 − and has first digit a. Now, · 106m 1 − = (142857) . 7 m It is easy to see that a can only be 1 or 2. Therefore, the only right-transferrable numbers are (142857)m and (285714)m with k =3: 3 (142857) = (428571) , × m m 3 (285714) = (857142) . × m m 2.2 Left-transferrable integers 113
2.2 Left-transferrable integers
A positive integer is left-transferrable if moving its rightmost digit to the leftmost results in a multiple of the number. Suppose Y is a left- transferrable with rightmost digit b. Then
n 1 Y b b 10 − + − = kY · 10 for an integer k. From this,
(10k 1)Y = b(10n 1). − −
Again, k =1 if and only if Y = bn. We shall assume k> 1. Note that for k = 2, 3, 6, 8, 9, p = 10k 1 is a prime number p > 10 > b. It divides 10n 1. By Fermat’s theorem,− the order of 10 mod p is a divisor of p 1. − −
k n 2 19Y = b(10n 1) 19 10n 1 18m 3 29Y = b(10n − 1) 29|10n − 1 28m 4 39Y = b(10n − 1) b =3| , 6−, 9; 39 10n 1 6m 5 49Y = b(10n − 1) b =7;6 49 10n | 1− 42m − b =7;6 7 10| n −1 6m 6 59Y = b(10n 1) 59 10n | 1− 58m 7 69Y = b(10n − 1) b =3| , 6−, 9; 69 10n 1 22m 8 79Y = b(10n − 1) 796 10n 1| − 13m 9 89Y = b(10n − 1) 89|10n − 1 44m − | −
Consider the case k =2. We have n = 18m. If we take n = 18, then
b(1018 1) Y = − = b 52631578947368421. 19 ×
1018 1 Note that A = 19− = 52631578947368421 has only 17 nonzero digits, we treat it as an 18-digit number 052631578947368421. For each b(1018 1) − b =1,..., 9, the number Yb = 19 is right-transferrable with k =2: 114 Transferrable numbers
b b A rightmost digit to leftmost × 1 052631578947368421 105263157894736842 2 105263157894736842 210526315789473684 3 157894736842105263 315789473684210526 4 210526315789473684 421052631578947368 5 263157894736842105 526315789473684210 6 315789473684210526 631578947368421052 7 368421052631578947 736842105263157894 8 421052631578947368 842105263157894736 9 473684210526315789 947368421052631578
More generally, for each of these Yb and arbitrary positive integer m,
Yb,m = Yb ((1017)m 1)1=(Yb)m × − is also left-transferrable with k =2.
Proof. Write Yb = Xbb for a 17-digit number Xb. Transferring the right- most digit of (Yb)m to the leftmost, we have (bX ) = (2 Y ) =2 (Y ) . b m × b m × b m
The same holds for the other values of k > 1 as shown in the table below, except for k =5, where we also have 714285 = 5 142857. ×
k p 2 19 052631578947368421 3 29 0344827586206896551724137931 4 025641 5 020408163265306122448979591836734693877551 142857 6 59 016949152542372881355932203389830508474576271186440∗ 6779661 7 0144927536231884057971 8 79 0126582278481 9 89 01123595505617977528089887640449438202247191 2.2 Left-transferrable integers 115
Exercise 1. What digits should be substituted for the letters so that the sum of the nine identical addends will be a repunit?
REPUNITS REPUNITS REPUNITS REPUNITS REPUNITS REPUNITS REPUNITS REPUNITS + REPUNITS
2. Are two repunits with consecutive even numbers as their subscripts relatively prime? 3. Are two repunits with consecutive numbers as their subscripts rel- atively prime? 4. Are two repunits with consecutive odd numbers as their subscripts relatively prime? 5. What digit does each letter of this multiplication represent?
RRRRRRR RRRRRRR REPUNIT× INUPER
6. An old car dealer’s record in the 1960’s shows that the total receipts for the sale of new cars in one year came to 1, 111, 111.00 dollars. If each car had eight cylinders and was sold for the same price as each other car, how many cars did he sell? (Note: This riddle was written before the inflation in the 1980’s). 7. If a Mersenne number M =2p 1 is prime, is the corresponding p − repunit 1p also prime? 116 Transferrable numbers Chapter 3
Arithmetic problems
3.1 A number game of Lewis Carroll
How would you get A from D?
Take a secret number A Multiply it by 3 Tell me if it is even or odd Do the corresponding routine as instructed below. Multiply by 3 Tell me if it is even or odd Do the corresponding routine B Add 19 to the original number A and put an extra digit at the end C Now add B and C Divide by 7 and get the quotient only Further divide by 7 and get the quotient only D Tell me this D and I shall give you back your A
odd routine: Add 5 or 9, then divide by 2, and then add 1. • even routine: Subtract 2 or 6, then divide by 2, and then add 29 or • 33 or 37. 118 Arithmetic problems
Solution. A can be obtained from D by (i) forming 4D 15, (ii) subtracting 3−if the first parity answer is even, and (iii) subtracting 2 if the second parity answer is even. Analysis.
e and e′ are either 0 or 1. • f and f ′ are 1, 0, or 1. • − g is an integer between 0 and 9. • The last two steps of dividing by 7 and keeping the quotients can • be combined into one single step of dividing by 49.
A 4k + 1 4k + 2 4k + 3 4k + 4 3A 12k + 3 12k + 6 12k + 9 12k + 12 Parity odd even odd even Routine 6k +5+2e 6k + 35 6k +8+2e 6k + 38 −2e + 4f −2e + 4f 3 times 18k + 15 + 6e 18k + 105 18k + 24 + 6e 18 + 114 −6e + 12f −6e + 4f Parity odd odd even even Routine B 9k + 11 9k + 56 9k + 43 9k + 89 ′ ′ ′ ′ +3e + 2e −3e + 2e +3e − 2e −3e − 2e ′ ′ +6f +4f +6f + 4f C 40k + 200 + g 40k + 210 + g 40k + 220 + g 40k + 230 + g B + C 49k + 211 + g 49k + 266 + g 49k + 263 + g 49k + 319 + g +3e + 2e′ −3e + 2e′ +3e − 2e′ −3e − 2e′ ′ ′ +6f +4f +6f + 4f lower bound 49k + 211 49k + 257 49k + 257 49k + 304 upper bound 49k + 225 49k + 283 49k + 279 49k + 318 D k + 4 k + 5 k + 5 k + 6 A 4D − 15 4D − 18 4D − 17 4D − 20 3.1 A number game of Lewis Carroll 119
Exercise 1. There is a list of n statements. For k = 1, 2,...,n, the k-th state- ment reads:
The number of false statements in this list is greater than k.
Determine the truth value of each of the statements.
Answer. n must be an odd number. Write n =2m +1. Statements 1,..., m are true, and statements m+1,..., n are false. 2. A man rowing upstream passes a log after a miles, then contin- ues for b hours, and then rows downstream, meeting the log at his starting point. What is the rate of the stream? 3. If a man takes h hours to make a certain trip, how much faster must he travel to make a trip m miles longer in the same time? 4. The ratio of the speeds of two trains is equal to the ratio of the time they take to pass each other going in the same direction to the time they take to pass each other in the opposite direction. Find the ratio of the speeds of the two trains. 5. You and I are walking toward each other along a straight road, each at a steady speed. A truck (also traveling at a steady speed) passes you in one second, and one second later it reaches me. One second after the truck has passed me, you and I meet. How long does the truck take to pass me? 6. The two hands of a clock have the same length. One can, neverthe- less, normally tell the correct time. For example, when the hands point at 6 and 12, it must be 6 O’clock, and cannot be otherwise. In every 12 hours period, there are, however, a number of occa- sions when it is impossible to tell the time. Exactly how many such occasions are there? 120 Arithmetic problems
3.2 Reconstruction of multiplications and divisions
3.2.1 A multiplication problem A multiplication of a three-digit number by 2-digit number has the form in which all digits involved are prime numbers. Reconstruct the multi- plication. (Note that 1 is not a prime number).
p p p p p × p p p p p ppp p pppp 3.2 Reconstruction of multiplications and divisions 121
3.2.2 A division problem
This is Problem E1 of the AMERICAN MATHEMATICAL MONTHLY:
x 7 x x x x x x) xxxxxxxx xxxx x x x x x x xxxx x x x xxxx xxxx
Clearly, the last second digit of the quotient is 0. Let the divisor be the 3-digit number d. Consider the 3-digit number in the seventh line, which is a multiple of d. Its difference from the 4-digit number in the sixth line is a 2-digit number. This must be 9xx. This cannot be the same as the 3-digit number in the fifth line, since the difference between the 3-digit numbers in the fourth and fifth lines is a 3-digit number. Therefore, in the quotient, the digit after 7 is a larger one, which must be smaller than the first and the last digits, since these give 4-digit multiples of d. It follows that the quotient is 97809. Since 8d is a 3-digit number 9xx, the 4-digit number in the third and bottom lines is 9d = 10xx or 11xx. From this 8d must be 99x, and therefore 992 = 8 124. × 97809 124)12128316 1116 9 6 8 8 6 8 1003 9 9 2 1116 1116 122 Arithmetic problems
Exercise
Reconstruct the following division problems.
1.
) ∗∗∗∗∗2 ∗ ∗ ∗∗∗∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗
2.
) ∗∗∗∗∗9 ∗ ∗ ∗∗∗∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗
3.
x x 8 x x x x x) xxxxxxxx x x x xxxx x x x xxxx xxxx 3.2 Reconstruction of multiplications and divisions 123
4. xxxxxx x x x) xxxxxxxx x x x xxxx x x x xxxx x x x xxxx xxxx Chapter 4
Fibonacci numbers
4.1 The Fibonacci sequence
The Fibonacci numbers Fn are defined recursively by
Fn+1 = Fn + Fn 1, F0 =0, F1 =1. − The first few Fibonacci numbers are n 0123456 7 8 9 1011 12 . . . Fn 0 1 1 2 3 5 8 13 21 34 55 89 144 . . .
An explicit expression can be obtained for the Fibonacci numbers by finding their generating function, which is the formal power series
F (x) := F + F x + + F xn + . 0 1 ··· n ··· From the defining relations, we have
F x2 = F x x + F x2, 2 1 · 0 · F x3 = F x2 x + F x x2, 3 2 · 1 · F x4 = F x3 x + F x2 x2, 4 3 · 2 · . . n n 1 n 2 2 Fnx = Fn 1x − x + Fn 2x − x , − · − · . . 202 Fibonacci numbers
Combining these relations we have F (x) (F + F x)= (F (x) F ) x + F (x) x2, − 0 1 − 0 · · F (x) x = F (x) x + F (x) x2, − · · (1 x x2)F (x)= x. − − Thus, we obtain the generating function of the Fibonacci numbers: x F (x)= . 1 x x2 − − There is a factorization of 1 x x2 by making use of the roots of the quadratic polynomial. Let α− > β−be the two roots. We have α + β =1, αβ = 1. − More explicitly, √5+1 √5 1 α = , β = − . 2 − 2
Now, since 1 x x2 = (1 αx)(1 βx), we have a partial fraction decomposition − − − − x x 1 1 1 = = . 1 x x2 (1 αx)(1 βx) α β 1 αx − 1 βx − − − − − − − 1 1 Each of 1 αx and 1 βx has a simple power series expansion. In fact, making use− of −
1 ∞ =1+ x + x2 + + xn + = xn, 1 x ··· ··· n=0 − X and noting that α β = √5, we have − x 1 ∞ ∞ = αnxn βnxn 1 x x2 √ − 5 n=0 n=0 ! − − X X ∞ αn βn = − xn. √ n=0 5 X The coefficients of this power series are the Fibonacci numbers: αn βn Fn = − , n =0, 1, 2,.... √5 4.1 The Fibonacci sequence 203
n n 1. F is the integer nearest to α : F = α . n √5 n √5 n o Proof. αn βn 1 1 F = < < . n − √ √ √ 2 5 5 5
2. For n 2, F = αF . ≥ n+1 { n} Proof. Note that
n n+1 αβ β α β n n Fn+1 αFn = − − β = β . − = √5 · For n 2, ≥ 1 F αF = β n < . | n+1 − n| | | 2
Fn+1 3. limn = α. →∞ Fn
Exercise 1. (a) Make use of only the fact that 987 is a Fibonacci number to confirm that 17711 is also a Fibonacci number, and find all inter- mediate Fibonacci numbers. (b) Make use of the result of (a) to decide if 75026 is a Fibonacci number. 2. Prove by mathematical induction the Cassini formula:
2 n Fn+1Fn 1 Fn =( 1) . − − −
3. The conversion from miles into kilometers can be neatly expressed by the Fibonacci numbers.
miles 5 8 13 kilometers 8 13 21 204 Fibonacci numbers
How far does this go? Taking 1 meter as 39.37 inches, what is the largest n for which Fn miles can be approximated by Fn+1 kilome- ters, correct to the nearest whole number? 4. Prove the Fermat Last Theorem for Fibonacci numbers: there is no solution of xn + yn = zn, n 2, in which x, y, z are (nonzero) Fibonacci numbers. ≥
4.2 Some relations of Fibonacci numbers
1. Sum of consecutive Fibonacci numbers: n F = F 1. k n+2 − k X=1
2. Sum of consecutive odd Fibonacci numbers: n
F2k 1 = F2n. − k X=1
3. Sum of consecutive even Fibonacci numbers: n F = F 1. 2k 2n+1 − k X=1
4. Sum of squares of consecutive Fibonacci numbers:
n 2 Fk = FnFn+1. k X=1
5. Cassini’s formula:
2 n Fn+1Fn 1 Fn =( 1) . − − − 4.3 Fibonacci numbers and binomial coefficients 205
4.3 Fibonacci numbers and binomial coefficients
x x Rewriting the generating function 1 x x2 = 1 (x+x2) as − − −
x + x(x + x2) + x(x + x2)2 + x(x + x2)3 + x(x+2)4 + · · · = x + x2(1 + x) + x3(1 + x)2 + x4(1 + x)3 + x5(1 + x)4 + · · · = x + x2 + x3 + x4 + x5 + · · · + x3 + 2x4 + 3x5 + 4x6 + · · · + x5 + 3x6 + 6x7 + · · · + x7 + 4x8 + · · · + x9 + · · · . + . we obtain the following expressions of the Fibonacci numbers in terms of the binomial coefficents:
0 F1 = = 1, 0! 1 F2 = = 1, 0! 2 1 F3 = + = 2, 0! 1! 3 2 F4 = + =1+2=3, 0! 1! 4 3 2 F5 = + + =1+3+1=5, 0! 1! 2! 5 4 3 F6 = + + =1+4+3=8, 0! 1! 2! 6 5 4 3 F7 = + + + =1+5+6+1=13, 0! 1! 2! 3! 7 6 5 4 F8 = + + + =1+6+10+4=21, 0! 1! 2! 3! . . 206 Fibonacci numbers
Theorem 4.1. For k 0, ≥ k ⌈ 2 ⌉ k j F = − . k+1 j j=0 X Proof.
x ∞ = x (x + x2)n 1 x x2 · n=0 − − X ∞ = xn+1(1 + x)n n=0 X n ∞ n = xn+1 xm m n=0 m=0 X n X ∞ n = xn+m+1 m n=0 m=0 X Xk 2 ∞ ⌈ ⌉ k j = − xk+1. j k j=0 X=1 X Chapter 5
Counting with Fibonacci numbers
5.1 Squares and dominos
In how many ways can a 1 n rectangle be tiled with unit squares and dominos (1 2 squares)? × 3 × 3 3 3 2 2 2 2 1 0 1 2 3 4 5 1 7 8 9 1011121 1415161718191 212223242526 0 0 0 0 0 1 2 3 4 5 7 8 9 101112 141516171819 212223242526 Suppose there are an ways of tiling a 1 n rectangle. There are two types of such tilings. × (i) The rightmost is tiled by a unit square. There are an 1 of these tilings. − (ii) The rightmost is tiled by a domino. There are an 2 of these. There- fore, − an = an 1 + an 2. − − Note that a1 =1 and a2 =2. These are consecutive Fibonacci numbers: a1 = F2 and a2 = F3. Since the recurrence is the same as the Fibonacci sequence, it follows that a = F for every n 1. n n+1 ≥ 208 Counting with Fibonacci numbers
5.2 Fat subsets of [n]
A subset A of [n] := 1, 2 ...,n is called fat if for every a A, a A (the number of{ elements} of A). For example, A = 4,∈5 is fat≥ but | B| = 2, 4, 5 is not. Note that the empty set is fat. How many{ } fat subsets does{[n] have?} Solution. Suppose there are bn fat subsets of [n]. Clearly, b1 =2 (every subset is fat) and b2 =3 (all subsets except [2] itself is fat). Here are the 5 fat subsets of [3]: , 1 , 2 , 3 , 2, 3 . ∅ { } { } { } { }
There are two kinds of fat subsets of [n]. (i) Those fat subsets which do not contain n are actually fat subsets of [n 1], and conversely. There are bn 1 of them. (ii)− Let A be a fat subset of m elements− and n A. If m = 1, then A = n . If m > 1, then every element of A is∈ greater than 1. The subset{ } A′ := j 1 : j < n, j A { − ∈ } has m 1 elements, each m 1 since j m for every j A. Note − ≥ − ≥ ∈ that A′ does not contain n 1. It is a fat subset of [n 2]. There are − − bn 2 such subsets. −We have established the recurrence
bn = bn 1 + bn 2. − − This is the same recurrence for the Fibonacci numbers. Now, since b1 =2= F3 and b2 =3= F4, it follows that bn = Fn+2 for every n 1. ≥ Exercise 1. (a) How many permutations π : [n] [n] satisfy → π(i) i 1, i =1, 2,...,n ? | − | ≤
(b) Let π be a permutation satisfying the condition in (a). Suppose for distinct a, b [n], π(a)= b. Prove that π(b)= a. ∈ 5.3 An arrangement of pennies 209
5.3 An arrangement of pennies
Consider arrangements of pennies in rows in which the pennies in any row are contiguous, and each penny not in the bottom row touches two pennies in the row below. For example, the first one is allowed but not the second one:
How many arrangements are there with n pennies in the bottom row? Here are the arrangements with 4 pennies in the bottom, altogether 13.
Solution. Let an be the number of arrangements with n pennies in the bottom. Clearly
a1 =1, a2 =3, a3 =5, a4 = 13.
A recurrence relation can be constructed by considering the number of pennies in the second bottom row. This may be n 1, n 2,..., 1, and also possibly none. − −
an = an 1 +2an 2 + +(n 1)a1 +1. − − ··· − 210 Counting with Fibonacci numbers
Here are some beginning values:
n an 1 1 2 2 3 5 4 5+2 2+3 1+1=13, 5 13+2 5+3· 2+4· 1+1=34, 6 34+2 13+3· 5+4· 2+5· 1+1=89, . · · · · . These numbers are the old Fibonacci numbers:
a1 = F1, a2 = F3, a3 = F5, a4 = F7, a5 = F9, a6 = F11.
From this we make the conjecture an = F2n 1 for n 1. − ≥ Proof. We prove by mathematical induction a stronger result:
an = F2n 1, − n
ak = F2n. k X=1 These are clearly true for n =1. Assuming these, we have
an+1 = an +2an 1 +3an 2 + + na1 +1 − − ··· = (an + an 1 + an 2 + + a1) − − ··· +(an 1 +2an 2 + +(n 1)a1 + 1) − − ··· − = F2n + an
= F2n + F2n 1 − = F2n+1; n+1 n
ak = an+1 + ak k k X=1 X=1 = F2n+1 + F2n
= F2(n+1). Therefore, the conjecture is established for all positive integers n. In particular, an = F2n 1. − Chapter 6
Fibonacci numbers 3
6.1 Factorization of Fibonacci numbers
1. gcd(Fm, Fn)= Fgcd(m,n).
2. If m n, then F F . | m| n 3. Here are the beginning values of F F : 2n ÷ n
n Fn F2n Ln = F2n Fn 111 1 ÷ 213 3 328 4 4321 7 55 55 11 6 8 144 18 7 13 377 29 8 21 987 47 . .
(a) These quotients seem to satisfy the same recurrence as the Fi- bonacci numbers: each number is the sum of the preceding two. (b) Therefore, it is reasonable to expect that each of these quo- tients can be expressed in terms of Fibonacci numbers. 212 Fibonacci numbers 3
n Fn F2n Ln = F2n Fn Fn 1 + Fn+1 − 111 1 ÷ 213 3 =1+2 328 4 =1+3 4321 7 =2+5 55 55 11 =3+8 6 8 144 18 =5+13 713377 29 =8+21 8 21987 47 =13+34 . .
(c) Conjectures: (a) Ln+2 = Ln+1 + Ln, L1 =1, L2 =3; (b) Ln = Fn+1 + Fn 1. − 4. These conjectures are true. They are easy consequences of Theorem 6.1 (Lucas’ Theorem). 2 2 F2n = Fn+1 Fn 1, − 2 − 2 F2n+1 = Fn+1 + Fn . Proof. We prove this by mathematical induction. These are true for n =1. Assume these hold. Then
F2n+2 = F2n+1 + F2n 2 2 2 2 = (Fn+1 + Fn )+(Fn+1 − Fn−1) 2 2 2 2 = (Fn+1 + Fn+1)+(Fn − Fn−1) 2 2 = Fn+1 + Fn+1 +(Fn + Fn−1)(Fn − Fn−1) 2 2 = Fn+1 + Fn+1 + Fn+1(Fn − Fn−1) 2 = Fn+1 + Fn+1(Fn+1 +(Fn − Fn−1)) 2 = Fn+1 + Fn+1(Fn +(Fn+1 − Fn−1)) 2 = Fn+1 + 2Fn+1Fn 2 2 2 = Fn+1 + 2Fn+1Fn + Fn − Fn 2 2 = Fn+2 − Fn ;
F2n+3 = F2n+2 + F2n+1 2 2 2 2 = (Fn+2 − Fn )+(Fn+1 + Fn ) 2 2 = Fn+2 + Fn+1. 6.1FactorizationofFibonaccinumbers 213
Therefore the statements are true for all n.
5. By Lucas’ theorem,
2 2 F2n = Fn+1 Fn 1 =(Fn+1 Fn 1)(Fn+1+Fn 1)= Fn(Fn+1+Fn 1). − − − − − −
If we put Ln = Fn+1 + Fn 1, then L1 = F2 + F0 = 1, L2 = − F1 + F3 =1+2=3, and
Ln+2 = Fn+3 +Fn+1 =(Fn+2 +Fn)+(Fn+1 +Fn 1)= Ln+1 +Ln. −
6. If Fn is prime, then n is prime. The converse is not true. Of course, F2 = 1 is not a prime. What is the least odd prime p for which Fp is not prime?
7. Apart from F0 = 0 and F1 = F2 = 1, there is only one more Fibonacci number which is a square. What is this? 214 Fibonacci numbers 3
6.2 The Lucas numbers
The sequence (Ln) satisfyin
Ln+2 = Ln+1 + Ln, L1 =1, L2 =3,
is called the Lucas sequence, and Ln the n-th Lucas number. Here are the beginning Lucas numbers.
n 1 2 3 4 5 6 7 8 9 10 11 12 Ln 1 3 4 7 11 18 29 47 76 123 199 322
Let α > β be the roots of the quadratic polynomial x2 x 1. − − n n 1. Ln = α + β .
2. Ln+1 + Ln 1 =5Fn. − 3. F k = L L L L L k−1 . 2 1 2 4 8 ··· 2 4. L1 =1 and L3 =4 are the only square Lucas numbers (U. Alfred, 1964).
Exercise
2 n 1 1. Prove that L = L + 2( 1) − . 2n n − Solution.
2n 2n L2n = α + β = (αn + βn)2 2(αβ)n − = L2 2( 1)n. n − − 2. Express F F in terms of L . 4n ÷ n n Solution.
3 n 1 F = F L = F L L = F (L + 2( 1) − L ). 4n 2n 2n n n 2n n n − n 3. Express F F in terms of L . 3n ÷ n n Answer. F = F (L2 +( 1)n). 3n n n − 6.3 Counting circular permutations 215
6.3 Counting circular permutations
Let n 4. The numbers 1, 2,..., n are arranged in a circle. How many permutations≥ are there so that each number is not moved more than one place? Solution. (a) π(n)= n. There are Fn permutations of [n 1] satisfying π(i) i 1. − | (b)−π(|n ≤)=1. (i) If π(1) = 2, then π(2) = 3,..., π(n 1) = n. (ii) If π(1) = n, then π restricts to a permutation− of [2,...,n 1] satis- − fying π(i) i 1. There are Fn 1 such permutations. (c)|π(n)=− n| ≤ 1. − (i) If π(n 1) =−n 2, then π(n 2) = n 3,..., π(2) = 1, π(1) = n. (ii) If π(n− 1) = n−, then π restricts− to a permutation− of [1, n 2] satis- − − fying π(i) i 1. There are Fn 1 such permutations. | − | ≤ −
Therefore, there are altogether Fn + 2(Fn 1 +1) = Ln + 2 such circular permutations. − For n =4, this is L4 +2=9. 4 4 4
4 4 4
3 3 1 1 3 3 1 2 2 3 1 1
2 2 2
2 1 3
1 1 1
4 4 4
4 3 1 2 3 3 1 4 2 3 1 4
2 2 2
3 2 3
3 3 3
4 4 4
2 3 1 4 4 3 1 1 4 3 1 2
2 2 2
1 2 1 Chapter 7
Subtraction games
7.1 The Bachet game
Beginning with a positive integer, two players alternately subtract a pos- itive integer 7.2 The Sprague-Grundy sequence Let G be a two-person counter game in which two players alternately re- move a positive amount of counters according to certain specified rules. The Sprague-Grundy sequence of G is the sequence (g(n)) of nonnega- tive integers defined recursively as follows. (1) g(n)=0 for all n which have no legal move to another number. In particular, g(0) = 0. (2) Suppose from position n it is possible to move to any of positions m1, m2,..., mk, (all < n), then g(n) is the smallest nonnegative integer different from g(m1), g(m2),..., g(mk). Theorem 7.1. The player who secures a position n with g(n)=0 has a winning strategy. Example 7.1. The Bachet game: n g(n) ← 0 0 1 0 1 2 1, 0 2 3 2, 1, 0 3 . . d 1 (d 2),..., 1, 0 d 1 −d (d − 1),..., 1 −0 . − . More generally, g(kd + a) = a for integers k and a satisfying 0 a 7.3 Subtraction of powers of 2 n g(n) ← 0 0 1 0 1 2 1, 0 2 3 2, 1 0 4 3, 2, 0 1 5 4, 3, 1 2 6 5, 4, 2 0 7 6, 5, 3 1 8 7, 6, 4, 0 2 9 8, 7, 5, 1 0 10 9, 8, 6, 2 1 This suggests that the winning positions are the multiples of 3. Proof. If Player A occupies a multiple of 3, any move by Player B will results in a position 3k +1 or 3k +2. Player A can get to a smaller multiple of 3 by subtracting 1 or 2 accordingly. Exercise 1. What are the winning positions in the game of subtraction of pow- ers of 3? Answer. Even numbers. 2. What are the winning positions in the game of subtraction of prime numbers or 1? Answer. Multiples of 4. 3. What are the winning positions in the game of subtraction of a proper divisor of the current number (allowing 1 but not the number itself) ? Note that 1 is not a proper divisor of itself Answer. Odd numbers except 1. Solution. The clue is that all factors of an odd number are odd. Subtracting an odd leaves an even number. Hence the winning strategy is to leave an odd number so that you opponent will always leave you an even number. From this you get to an odd number by subtracting 1. 304 Subtraction games 7.4 Subtraction of square numbers Two players alternately subtract a positive square number. We calculate the Sprague-Grundy sequence. n g(n) ← 0 0 1 0 1 2 1 0 3 2 1 4 3, 0 2 5 4, 1 0 6 5, 2 1 7 6, 3 0 8 7, 4 1 9 8, 5, 0 2 10 9, 6, 1 0 The values of n 500 for which g(n)=0 are as follows: 1 These are the winning positions.≤ 0 2 5 7 10 12 15 17 20 22 34 39 44 52 57 62 65 67 72 85 95 109 119 124 127 130 132 137 142 147 150 170 177 180 182 187 192 197 204 210 215 238 243 249 255 257 260 262 267 272 275 312 317 322 327 332 335 340 345 350 369 377 390 392 397 425 430 437 442 447 449 464 Suppose we start with 74. Player A can subtract 9 to get to 65, or subtract 64 to get 10, which have value 0. In the latter case, B may move to 9, 6 or 1. A clearly wins if B moves to 9 or 1. But if B moves to 6, then A can move to 5 or 2 and win. Exercise 1. How would you win if the starting number is 200? or 500? 1[Smith, p.68] incorrectly asserts that this sequence is periodic, with period 5. 7.5 More difficult games 305 7.5 More difficult games 1. Subtraction of proper divisor of current number (not allowing 1 and the number itself). The winning positions within 500 are as follows. 0 1 2 3 5 7 8 9 11 13 15 17 19 21 23 25 27 29 31 32 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 128 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255 257 259 261 263 265 267 269 271 273 275 277 279 281 283 285 287 289 291 293 295 297 299 301 303 305 307 309 311 313 315 317 319 321 323 325 327 329 331 333 335 337 339 341 343 345 347 349 351 353 355 357 359 361 363 365 367 369 371 373 375 377 379 381 383 385 387 389 391 393 395 397 399 401 403 405 407 409 411 413 415 417 419 421 423 425 427 429 431 433 435 437 439 441 443 445 447 449 451 453 455 457 459 461 463 465 467 469 471 473 475 477 479 481 483 485 487 489 491 493 495 497 499 2. Subtraction of primes (not allowing 1). The winning positions within 500 are as follows. 0 1 9 10 25 34 35 49 55 85 91 100 115 121 125 133 145 155 169 175 187 195 205 217 235 247 253 259 265 289 295 301 309 310 319 325 335 343 355 361 375 385 391 395 403 415 425 445 451 469 475 481 485 493 306 Subtraction games Chapter 8 The games of Euclid and Wythoff 8.1 The game of Euclid Two players alternately remove chips from two piles of a and b chips respectively. A move consists of removing a multiple of one pile from the other pile. The winner is the one who takes the last chip in one of the piles. Preliminary problem: Find a constant k such that for positive integers a and b satisfying bk(a b), (ii) a>kb =⇒ b