problem solving and recreational mathematicsmath.fau.edu/yiu/psrm2015/psrm2015chapters1to8.pdf ·...

53
Problem Solving and Recreational Mathematics Paul Yiu Department of Mathematics Florida Atlantic University Summer 2015 Chapters 1–8 June 22, 2015 Monday 6/29 7/6 7/13 7/20 7/27 8/3 Wednesday 6/24 7/1 7/8 7/15 7/22 7/29 Friday 6/26 *** 7/10 7/17 7/24 7/31

Upload: lamthien

Post on 28-Feb-2018

254 views

Category:

Documents


6 download

TRANSCRIPT

Problem Solving andRecreational Mathematics

Paul Yiu

Department of MathematicsFlorida Atlantic University

Summer 2015

Chapters 1–8

June 22, 2015

Monday 6/29 7/6 7/13 7/20 7/27 8/3Wednesday 6/24 7/1 7/8 7/15 7/22 7/29Friday 6/26 *** 7/10 7/17 7/24 7/31

Contents

1 Arithmetic Problems 1011.1 Reconstruction of division problems . . . . . . . . . . 101

1.1.1 AMM E1 . . . . . . . . . . . . . . . . . . . . . 1011.1.2 AMM E10 . . . . . . . . . . . . . . . . . . . . 1031.1.3 AMM E1111 . . . . . . . . . . . . . . . . . . . 1041.1.4 AMM E971 . . . . . . . . . . . . . . . . . . . . 1051.1.5 AMM E198 . . . . . . . . . . . . . . . . . . . . 106

2 Digit problems 1072.1 When can you cancel illegitimately and yet get the cor-

rect answer? . . . . . . . . . . . . . . . . . . . . . . . 1072.2 Repdigits . . . . . . . . . . . . . . . . . . . . . . . . . 1092.3 Sums of squares of digits . . . . . . . . . . . . . . . . 112

3 Representation of a number in different bases 1153.1 Base b-representation of a number . . . . . . . . . . . . 115

3.1.1 A number from its base b-representation . . . . . 1163.2 The Josephus problem . . . . . . . . . . . . . . . . . . 119

4 Representation of a number in different bases 1214.1 Balanced division by an odd number . . . . . . . . . . 1214.2 Balanced base b representation of a number . . . . . . . 1214.3 Arithmetic in balanced base 3 representations . . . . . 123

4.3.1 A matrix card trick . . . . . . . . . . . . . . . . 124

5 Cheney’s card trick 1275.1 Three basic principles . . . . . . . . . . . . . . . . . . 127

5.1.1 The pigeonhole principle . . . . . . . . . . . . . 1275.1.2 Arithmetic modulo 13 . . . . . . . . . . . . . . 127

iv CONTENTS

5.1.3 Permutations of three objects . . . . . . . . . . . 1285.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . 1295.3 A variation: Cheney card trick with spectator choosing

secret card . . . . . . . . . . . . . . . . . . . . . . . . 131

6 The nim game 1336.1 The nim sum . . . . . . . . . . . . . . . . . . . . . . . 1336.2 The nim game . . . . . . . . . . . . . . . . . . . . . . 134

7 Fibonacci and Lucas numbers 1377.1 The Fibonacci sequence . . . . . . . . . . . . . . . . . 1377.2 Some relations of Fibonacci numbers . . . . . . . . . . 1407.3 Zeckendorff representations . . . . . . . . . . . . . . . 1417.4 The Lucas numbers . . . . . . . . . . . . . . . . . . . 1427.5 How can we know if a given integer is a Fibonacci

number? . . . . . . . . . . . . . . . . . . . . . . . . . 1437.6 Periodicity of Fibonacci sequence mod m . . . . . . . 144

8 Counting with Fibonacci numbers 1458.1 Squares and dominos . . . . . . . . . . . . . . . . . . 1458.2 Fat subsets of [n] . . . . . . . . . . . . . . . . . . . . . 1468.3 An arrangement of pennies . . . . . . . . . . . . . . . 1478.4 Counting circular permutations . . . . . . . . . . . . . 149

Chapter 1

Arithmetic Problems

1.1 Reconstruction of division problems

1.1.1 AMM E1

This is Problem E1 of the AMERICAN MATHEMATICAL MONTHLY:

x 7 x x xx x x) x x x x x x x x

x x x xx x xx x xx x x x

x x xx x x xx x x x

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 ofd. Its difference from the 4-digit number in the sixth line is a 2-digitnumber. This must be 9xx.This cannot be the same as the 3-digit number in the fifth line, since thedifference between the 3-digit numbers in the fourth and fifth lines is a3-digit number.Therefore, in the quotient, the digit after 7 is a larger one, which must besmaller than the first and the last digits, since these give 4-digit multiplesof d.It follows that the quotient is 97809.

102 Arithmetic Problems

Since 8d is a 3-digit number 9xx, the 4-digit number in the third andbottom lines is 9d = 10xx or 11xx.From this 8d must be 99x, and therefore 992 = 8× 124.

9 7 8 0 91 2 4) 1 2 1 2 8 3 1 6

1 1 1 69 6 88 6 81 0 0 3

9 9 21 1 1 61 1 1 6

1.1 Reconstruction of division problems 103

1.1.2 AMM E10

This is Problem E10 of the MONTHLY, by Fitch Cheney. In this case,not even one single digit is given.

x x x x x xx x x) x x x x x x x x

x x xx x x x

x x xx x x x

x x xx x x xx x x x

104 Arithmetic Problems

1.1.3 AMM E1111

This is said to be the most popular MONTHLY problem. It appeared inthe April issue of 1954.

Our good friend and eminent numerologist, Professor EuclideParacelso Bombasto Umbugio, has been busily engaged test-ing on his desk calculator the 81 · 109 possible solutions to theproblem of reconstructing the following exact long divisionin which the digits indiscriminately were each replaced by xsave in the quotient where they were almost entirely omitted.

x x 8 x xx x x) x x x x x x x x

x x xx x x x

x x xx x x xx x x x

Deflate the Professor! That is, reduce the possibilities to (18 ·109)0.

Martin Gardner’s remark: Because any number raised to the powerof zero is one, the reader’s task is to discover the unique reconstructionof the problem. The 8 is in correct position above the line, making itthe third digit of a five-digit answer. The problem is easier than it looks,yielding readily to a few elementary insights.

1.1 Reconstruction of division problems 105

1.1.4 AMM E971

Reconstruct the division problem

∗ ∗ ∗ ∗ ∗∗ ∗) ∗ ∗ ∗ ∗ 2 ∗

∗ ∗∗ ∗ ∗

∗ ∗∗ ∗ ∗∗ ∗ ∗

∗ ∗∗ ∗

Charles Twigg comments that if the digit 2 is replaced by 9, the answeris also unique.

∗ ∗ ∗ ∗ ∗∗ ∗) ∗ ∗ ∗ ∗ 9 ∗

∗ ∗∗ ∗ ∗

∗ ∗∗ ∗ ∗∗ ∗ ∗

∗ ∗∗ ∗

106 Arithmetic Problems

1.1.5 AMM E198

Here is a multiplication problem:A multiplication of a three-digit number by 2-digit number has the formin 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 pp p p pp p p p p

Chapter 2

Digit problems

2.1 When can you cancel illegitimately and yet get thecorrect answer?

Let ab and bc be 2-digit numbers. When do such illegitimate cancella-tions as

abbc =

a �b�bc =

ac ,

allowing perhaps further simplifications of ac?

Answer. 1664

= 14, 1995

= 15, 2665

= 25, 4998

= 48.

Solution. We may assume a, b, c not all equal.Suppose a, b, c are positive integers ≤ 9 such that 10a+b

10b+c= a

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).

If c is not divisible by 5, then 9a + b is divisible by 5. The onlypossibilities of distinct (a, b) are (b, a) = (3, 8), (6, 1), (9, 4). Only the

108 Digit problems

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 furthersimplifications.

(a) �a �bc�b�ad = c

d,

(b) c �a�bd �b�a = c

d,

(c) a �b�c�b�cd = a

d.

2. Find all 4-digit numbers like 1805 = 192 × 5, which, when dividedby the its last two digits, gives the square of the number one morethan its first two digits.

2.2 Repdigits 109

2.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 digitseach equal to a. Thus,

an =a

9(10n − 1).

Example 2.1. Show that

16n6n4

=1

4,

19n9n5

=1

5,

26n6n5

=2

5,

49n9n8

=4

8.

Solution. More generally, we seek equalities of the form abnbnc

= ac

fordistinct integer digits a, b, c. Here, abn is digit a followed by n digitseach equal to b. To avoid confusion, we shall indicate multiplicationwith the sign ×.

The condition (abn)× c = (bnc)× a is equivalent to(10na+

b

9(10n − 1)

)c =

(10b

9(10n − 1) + c

)a,(

(10n − 1)a+b

9(10n − 1)

)c =

(10b

9(10n − 1)

)a.

Cancelling a common divisor 10n−19

, we obtain (9a+ b)c = 10ab, whichis the same condition for ab

bc= a

c.

Exercise

1. Complete the following multiplication table of repdigits.

1n 2n 3n 4n 5n 6n 7n 8n 9n1 1n 2n 3n 4n 5n 6n 7n 8n 9n2 4n 6n 8n 1n0 13n−12 15n−14 17n−16 19n−183 9n 13n−12 16n−15 19n−18 23n−11 26n−14 29n−174 17n−16 2n0 26n−14 31n−208 35n−12 39n−165 27n−15 3n0 38n−15 4n0 49n−156 39n−16 46n−12 53n−228 59n−147 54n−239 62n−216 69n−138 71n−204 79n−129 98n−201

2. Simplify (1n)(10n−15).

Answer. (1n)(10n−15) = 1n5n.

110 Digit problems

Exercise

1. Find the three 3-digit numbers each of which is equal to the productof the sum of its digits by the sum of the squares of its digits.

Answer. 133, 315, 803.

2. 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 21n3 1000 1331 1728 2197 2744 3375 4096 4913 5832 6859 8000 9261

∗ ∗ ∗ ∗ ∗ ∗

3. Use each digit 1, 2, 3, 4, 5, 6, 7, 8, 9 exactly once to form primenumbers whose sum is smallest possible.

What if we also include the digit 0?

4. There are exactly four 3-digit numbers each equal to the sum of thecubes of its own digits. Three of them are 153, 371, and 407. Whatis the remaining one?

5. Find all possibilities of a 3-digit number such that the three num-bers obtained by cyclic permutations of its digits are in arithmeticprogression.

Answer. 148, 185, 259, 296.

Solution. Let abc be one such 3-digit numbers, with a smallestamong the digits (which are not all equal). The other two numbersare 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 withdigit sum equal to s, and check if 37 × s = bca or cab. We mayignore multiples of 3 for k (giving repdigits for 37 × k). Note that3k < 27. We need only consider k = 4, 5, 7, 8.

k 37× k s 37× s arithmetic progression4 148 13 13× 37 = 481 148, 481, 8145 185 14 14× 37 = 518 185, 518, 8517 259 16 16× 37 = 592 259, 592, 9258 296 17 17× 37 = 629 296, 629, 962

2.2 Repdigits 111

6. 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 exactlyonce as pandigital (with 0 as the leftmost digit). In particular, thenumber A := 123456789 is pandigital.

There are exactly 33 positive integers n for which nA are pandigitalas shown below.

n nA n nA n nA

1 123456789 2 246913578 4 4938271565 617283945 7 864197523 8 98765431210 1234567890 11 1358024679 13 160493825714 1728395046 16 1975308624 17 209876541320 2469135780 22 2716049358 23 283950614725 3086419725 26 3209876514 31 382716045932 3950617248 34 4197530826 35 432098761540 4938271560 41 5061728349 43 530864192744 5432098716 50 6172839450 52 641975302853 6543209817 61 7530864129 62 765432091870 8641975230 71 8765432019 80 9876543120

How would you characterize these values of n?

7. 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.

112 Digit problems

2.3 Sums of squares of digits

Given a number N = a1a2 · · · an of n decimal digits, consider the “sumof digits” function

s(N) = a21 + a22 + · · ·+ a2n.

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 2.1. For every positive integer N , the sequence S(N) is eithereventually constant at 1 or periodic. The period has length 8 and form acycle

4

16

37

58

89

145

42

20

1

A proof of the theorem is outlined in the following exercise.

2.3 Sums of squares of digits 113

Exercise

1. Prove by mathematical induction that 10n−1 > 81n for n ≥ 4.

2. Prove that if N has 4 or more digits, then s(N) < N .

Solution. If N has n digits, then(i) N ≥ 10n−1,(ii) s(N) ≤ 81n.

From the previous exercise, for n ≥ 4, N ≥ 10n−1 > 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 . Thereforea = 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.

68

8628

82

19 91

1

10 100

13

31

130

23

32

79

97

44

49

94

7 70

114 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.

89

85

29

927667

52 25

64

46

34

43 5

50

80 8

35

53

71

17

84 48 22

72

27 14

41

66

45

54

36

63

660

4

2

11

113

78 87

42

20

145 58

16

37

24

98

77

73

38

83

40

62

26

51

117

69

128

88

61

106

59

95

56

65

81

47

18

74

33

57

75

9

90

3

30

39

93

Chapter 3

Representation of a number indifferent bases

3.1 Base b-representation of a number

Let b be a fixed positive integer. To write an integer n in base b, keepon dividing the number by b until the quotient is 0, and record the re-mainders, which are integers between 0 and b−1, from right to left. Theresulting sequence, which always begins with a nonzero leftmost digit,is the representation of n in base b.

Example 3.1. (a) 123 = [1111011]2

divisor quotient remainder2 123 1

61 130 015 17 13 11 10

116 Representation of a number in different bases

(b) 123 = [11120]3

divisor quotient remainder3 123 0

41 213 14 11 10

3.1.1 A number from its base b-representation

Given the base b representation of an integer:

n = [a0a1 · · · ak−1ak]b,

to find the integer in its decimal form, calculate a sequence of numbersn0, n1, . . . , nk as follows:(i) n0 = a0,(ii) for i = 1, 2, . . . , k, ni = ai + b · ni−1.

Then, n = nk.

Example 3.2. (a) [1111011]2 = 123.

1 1 1 1 0 1 12 2 6 14 30 60 122

1 3 7 15 30 61 123

(b) [23147]11 = 33447.

2 3 1 4 711 22 275 3036 33440

2 25 276 3040 33447

Example 3.3. Ask your friend to think of a number between 1 and 31.Then ask her if the number appears in card (a), (b), (c), (d), or (e). Nowadd up the numbers from the lower left hand corners of the card whichshe answers yes. That is the number she has chosen.

3.1 Base b-representation of a number 117

0 1 2 3 40

1

2

3

4

1

3

5

7

9

11

13

15

17

19

21

23

25

27

29

31

0 1 2 3 40

1

2

3

4

2

3

6

7

10

11

14

15

18

19

22

23

26

27

30

31

0 1 2 3 40

1

2

3

4

4

5

6

7

12

13

14

15

20

21

22

23

28

29

30

31

0 1 2 3 40

1

2

3

4

8

10

12

14

24

26

31

28

29

30

27

25

15

13

11

9

0 1 2 3 40

1

2

3

4

16

18

22

20

24

26

31

28

29

30

27

25

21

23

19

17

118 Representation of a number in different bases

Exercise

1. Complete the multiplication table in base 7.

1 2 3 4 5 6

1 1 2 3 4 5 62 23 3 124 45 56 6 15 51

2. Multiply in base 7:

[12346]7 × [06]7 =

[12346]7 × [15]7 =

[12346]7 × [24]7 =

[12346]7 × [33]7 =

[12346]7 × [42]7 =

[12346]7 × [51]7 =

3. Ask your friend to write down a polynomial f(x) with nonnegativeinteger coefficients. Ask her for the value of f(1). She returns7. Ask her for the value of f(8). She returns 4305. What is thepolynomial?

3.2 The Josephus problem 119

3.2 The Josephus problem

There are n people, numbered consecutively, standing in a circle. First,Number 2 sits down, then Number 4, Number 6, etc., continuing aroundthe circle with every other standing person sitting down until just oneperson is left standing. What number is this person?

This is Problem 1031 of MATHEMATICS MAGAZINE, a reformula-tion of the Josephus problem.

Here is M. Chamberlain’s solution:

Write n = 2m + k where 0 ≤ k ≤ 2m − 1.Then seat the people numbered 2, 4, . . . , 2k.This leaves 2m people standing, beginning with the personnumbered 2k + 1; call him Stan.Now continue to seat people until you get back to Stan.It is easy to see that 2m−1 people will be left standing, startingwith Stan again.On every subsequent pass of the circle half of those standingwill be left standing with Stan always the first among them.Stan’s the man.

1

2

34

5

6

7

8 9

10

8

1

62

*

3

7

4 9

5

Let J(n) be the position of the last standing man in a circle of n.

Theorem 3.1. The binary expansion of J(n) is obtained by transferringthe leftmost digit 1 of the binary expansion of n to the rightmost.

Proof. If n = 2m + k for k ≤ 2m, then J(n) = 2(n − 2m) + 1. Thebinary expansion of J(n) is obtained by moving the leftmost digit of thebinary expansion of n (corresponding to 2m) to the rightmost.

120 Representation of a number in different bases

Exercise

1. For what values of n is J(n) = n?

2. For what values of n is J(n) = n− 1?

Chapter 4

Representation of a number indifferent bases

4.1 Balanced division by an odd number

Given a positive integer b and a string of b consecutive integers, for everyinteger a, there are unique integers q and r so that

a = bq + r with r in the given string of b consecutive integers.

In particular, if b is odd, say b = 2c+ 1, we may choose the string ofremainders to be

−c, −(c− 1), . . . , −1, 0, 1, . . . , c− 1, c.

If we writea = bq + r, −c ≤ r ≤ c,

we say that this is the balanced division of a by the odd number b.

4.2 Balanced base b representation of a number

Let b be a positive odd number. The balanced base b representation ofan integer n is obtained by repeatedly performing balanced divisions byb and recording, from right to left, the remainders, which are integers inthe range − b−1

2, · · · ,−1, 0, 1, . . . , b−1

2. We shall write

1, 2, 3, 4, . . .

in place of the negative remainders

−1, −2, −3, −4, . . . .

122 Representation of a number in different bases

Examples

(1) 100 = 〈11011〉3divisor quotient remainder

3 100 133 011 14 11 10

The balanced ternary form of a number expresses it as a sum and/ordifferences of distinct powers of 3:

100 = 34 + 33 − 32 + 1.

Here is a simple application of the balanced ternary expansion ofnumbers.

Example 4.1. Suppose we have a beam balance and a set of seven stan-dard weights 1, 2, 4, 8, 16, 32, 64 units. It is possible to weigh everyinteger units from 1 to 127 with these seven standard weights. For ex-ample, since 1002 = 1100100, balance is achieved by putting a weightof 100 units on one pan, and standard weights of 4, 32 and 64 units onthe other.

However, with a set of five standard weights 1, 3, 9, 27, 81, it ispossible to weigh every integer units from 1 to 121. For example, since〈100〉3 = 11101, a weight of 100 units can be balanced by putting it witha standard weight 9 units on one pan and the standard weights 1, 27, 81on the other pan.

4.3 Arithmetic in balanced base 3 representations 123

4.3 Arithmetic in balanced base 3 representations

+ 1 0 11 11 1 00 1 0 11 0 1 11

× 1 0 11 1 0 10 0 0 01 1 0 1

Example 4.2. 〈11111〉3 × 〈1111〉3 = 〈11000011〉3.1 1 1 1 1

× 1 1 1 11 1 1 1 1

1 1 1 1 11 1 1 1 1

1 1 1 1 11 1 0 0 0 0 1 1

124 Representation of a number in different bases

4.3.1 A matrix card trick

Let p and q be given odd numbers, say p = 2h + 1 and q = 2k + 1.Arrange pq cards in the form of a p× q matrix. Ask a spectator to selectone secret card and name the column containing the secret card. Thenthe cards are(i) picked up along columns in any order, except that the named one isthe middle one, being preceded by k arbitrary columns and followed bythe remaining k columns arbitrarily,(ii) rearranged into the p× q matrix along rows.

Repeat a number of times, each time asking for the column whichcontains the secret card. The secret card will eventually appear exactlyin the middle row of the matrix.

If p ≤ q, you can tell what the secret card is after the first step. It isin the middle row.

We shall henceforth assume p > q so that there are more rows thancolumns.

Example 4.3. In the arrangement below, the spectator chooses ♦2 andtells you that it is in the second column.

♣5 ♠6 ♦8♣J ♠Q ♠K♥9 ♠A ♦6♦9 ♣6 ♥10♠10 ♦2 ♣9

Then you pick up, in order, the first, the second, and then the thirdcolumns, and deal the cards in rows:

♣5 ♣J ♥9♦9 ♠10 ♠6♠Q ♠A ♥6♦2 ♦8 ♠K♦6 ♥10 ♠9

Now ask the spectator which column contains the secret card. Shewill answer the first column. Then you pick up, in order, the third, thefirst, and the second column, and deal the cards in rows:

4.3 Arithmetic in balanced base 3 representations 125

♥9 ♠6 ♥6♠K ♠9 ♣5♦9 ♠Q ♦2♦6 ♣J ♠10♠A ♦8 ♥10

Now, the spectator will tell you that the secret card is in the thirdcolumn. You immediately know that the card is ♦2.

How many times do you need to rearrange the cards before you cantell what the secret card is? 1

Label the rows −h, −(h− 1), . . . , 0, . . . , h− 1, h so that the middlerow is row 0. An application of (i) and (ii) will bring the i-th card inthe column containing the secret card into row g(i), where g(i) is thequotient in the balanced division of i by q. Equivalently,

g(i) = b if i = bq + r for − k ≤ i ≤ k.

It is easy to see that g is an odd function: under the same condition,−i = −bq − r, with −k ≤ −r ≤ k, so that g(−i) = −b. Now, g(i)is decreasing for positive i, and increasing for i < 0. Furthermore, ifg(i) = 0, then all subsequent iterates by g are stationary at 0. Therefore,if we write p = 2h+ 1, then the number of times to guarantee the secretcard in the middle row is

min{� : g�(h) = 0}.The function g on positive integers can be easily described in terms

of the base q representations of numbers.

Lemma 4.1. If n = 〈amam−1 . . . a1a0〉q in balanced base q representa-tion, then

g(n) = 〈amam−1 · · · a1〉q.Proposition 4.2. The number of times for the secret card to move tothe middle row is not more than the length of the balanced base q-representation of the integer p−1

2.

Examples

(1) 51 cards in 3 columns: p = 17, q = 3. Since 8 = 〈101〉3, threeoperations suffice.

1G. R. Sanchis, A card trick and the mathematics behind it, College Math. Journal, 37 (2006) 103–109.Here, we make use of balanced base q representation of numbers.

126 Representation of a number in different bases

(2) 35 cards in 5 columns: p = 7, q = 5. Since 3 = 〈12〉5, twooperations suffice.

Exercise

Find the number of operations required to move the secret card to themiddle row for

1. 45 cards in 5 columns;

2. 39 cards in three columns.

Chapter 5

Cheney’s card trick

You are the magician’s assistant. What he will do is to ask a spectator togive you any 5 cards from a deck of 52. You show him 4 of the cards,and in no time, he will tell everybody what the 5th card is. This of coursedepends on you, and you have to do things properly by making use ofthe following three basic principles.

5.1 Three basic principles

5.1.1 The pigeonhole principle

Among 5 cards at least 2 must be of the same suit. So you and themagician agree that the secret card has the same suit as the first card.

5.1.2 Arithmetic modulo 13

The distance of two points on a 13-hour clock is no more than 6.

We decide which of the two cards to be shown as the first, and whichto be kept secret. For calculations, we treat A, J, Q, and K are respec-tively 1, 11, 12, and 13 respectively.

Now you can determine the distance between these two cards. Fromone of these, going clockwise, you get to the other by travelling thisdistance on the 13-hour clock. Keep the latter as the secret card.

128 Cheney’s card trick

hours distance clockwise2 and 7 5 2 to 73 and 10 6 10 to 32 and J 4 J to 2A and 8 6 8 to A

The following diagram shows that the distance between ♣3 and ♥10is 6, not 7.

♣3

♣2

♦A♠K♣Q

♥J

♥10

♦9

♣8

♦7 ♣6♥5

♦4

6

5.1.3 Permutations of three objects

There are 6 arrangements of three objects The remaining three cardscan be ordered as small, medium, and large. 1 Now rearrange themproperly to tell the magician what number he should add (clockwise) tothe first card to get the number on the secret card. Let’s agree on this:

arrangement distancesml 1slm 2msl 3mls 4lsm 5lms 6

If you, the assistant, want to tell the magician that he should add 4 tothe number (clockwise) on the first card, deal the medium as the secondcard, the large as the third, and the small as the fourth card.

1First by numerical order; for cards with the same number, order by suits: ♣ < ♦ < ♥ < ♠.

5.2 Examples 129

5.2 Examples

Example 5.1. Suppose you have ♠5, ♣7, ♦J, ♣4, and ♠Q, and youdecide to use the ♣ cards for the first and the secret ones. The distancebetween ♣7 and ♣4 is of course 3, clockwise from ♣4 to ♣7. Youtherefore show ♣4 as the first card, and arrange the other three cards,♠5, ♦J, and ♠Q, in the order medium, small, large. The second cardis ♦J, the third ♠5, and the fourth ♠Q. The secret card is ♣7.

4♣ J

♦ 5♠ Q

♠ ??

Example 5.2. Now to the magician. Suppose your assistant show youthese four cards in order:

Q♠ J

♦ 7♣ 4

♣ ??

Then you know that the secret card is a ♠, and you get the number byadding to Q the number determined by the order large, medium, small,which is 6. Going clockwise, this is 5. The secret card is ♠5.

Exercise

1. For the assistant:

(a) ♠5, ♠7, ♦6, ♣5, ♣Q.

(b) ♥2, ♠J, ♥K, ♣2, ♠8.

130 Cheney’s card trick

2. For the magician: what is the secret card?

5♠ 7

♠ 6♦ 5

♣ ??

2♥ J

♠ 2♣ 8

♠ ??

5.3 A variation: Cheney card trick with spectator choosing secret card 131

5.3 A variation: Cheney card trick with spectator choos-ing secret card

Now the spectators say they would choose the secret card. What shouldyou, the assistant, do?

1. Arrange the four open cards in ascending order, and put the n-thcard in the first position, with n = 1, 2, 3, 4, according as the secretcard is for ♣, ♦, ♥, or ♠. For example, if you are given ♠2, ♥6,♦K, ♠10, and ♣4 as secret card, then since

♠2 < ♥6 < ♠10 < ♦K,

you put ♠2 in the first position.

2. Note the rank of the secret card. If it is the same as the first card,put the secret card in the third position, and arrange the remainingthree in any order.

3. If the ranks of secret card and the first card are different, deter-mine the 13−point clock difference, and arrange the remainingthree open cards to indicate this difference.

(a) If the rank of the secret card is higher than that of the firstcard, put the secret card in the second position, followed bythe remaining three open cards in the positions indicating thedifference.

(b) If the rank of the secret card is lower than that of the first card,put the three open cards in the positions indicating the differ-ence, followed by the secret card.

2♠ ?

? 6♥ K

♦ 10♠

Now, for the magician,

132 Cheney’s card trick

1. Determine the order of the first card among the four open cards.The secret card is ♣, ♦, ♥, ♠ according as this is the least, second,third, or largest.

2. If the secret card appears in the third position, its rank is the sameas the rank of the first card.

3. If the secret card separates the first card from the remaining three,add the number determined by the remaining three cards to the firstcard to get the rank of the secret card.

4. If the secret card appears at the end, subtract the number deter-mined by the remaining three cards from the first card to get therank of the secret card.

Exercise

1. For the assistant:

(a) ♠5, ♠7, ♦6 (secret card), ♣5, ♣Q.

(b) ♥2, ♠J, ♥K, ♣2, ♠8 (secret card).

2. For the magician: what is the secret card?

5♠ ?

? 6♦ 5

♣ 7♠

2♥ J

♠ 2♣ 8

♠ ??

Chapter 6

The nim game

6.1 The nim sum

The nim sum of two nonnegative integers is the addition in their base 2notations without carries. If we write

0� 0 = 0, 0� 1 = 1� 0 = 1, 1� 1 = 0,

then in terms of the base 2 expansions of a and b,

a� b = (a1a2 · · · an)� (b1b2 · · · bn) = (a1 � b1)(a2 � b2) · · · (an � bn).

The nim sum is associative, commutative, and has 0 as identity ele-ment. In particular, a� a = 0 for every natural number a.

Example 6.1. (a) 6� 5 = [110]2 � [101]2 = [011]2 = 3.

(b) 34� 57 = [100010]2 � [111001]2 = [011011]2 = 27.

Here are the nim sums of numbers ≤ 15:

134 The nim game

� 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 151 1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 142 2 3 0 1 6 7 4 5 10 11 8 9 14 15 12 133 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 124 4 5 6 7 0 1 2 3 12 13 14 15 8 9 10 115 5 4 7 6 1 0 3 2 13 12 15 14 9 8 11 106 6 7 4 5 2 3 0 1 14 15 12 13 10 11 8 97 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 88 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 79 9 8 11 10 13 12 15 14 1 0 3 2 5 4 7 610 10 11 8 9 14 15 12 13 2 3 0 1 6 7 4 511 11 10 9 8 15 14 13 12 3 2 1 0 7 6 5 412 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 313 13 12 15 14 9 8 11 10 5 4 7 6 1 0 3 214 14 15 12 13 10 11 8 9 6 7 4 5 2 3 0 115 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

6.2 The nim game

Given three piles of marbles, with a, b, c marbles respectively, playersA and B alternately remove a positive amount of marbles from any pile.The player who makes the last move wins.

Theorem 6.1. In the nim game, the player who can balance the nim sumequation has a winning strategy.

Therefore, provided that the initial position (a, b, c) does not satisfya � b � c = 0, the first player has a winning strategy. For example,suppose the initial position is (12, 7, 9). Since 12 � 9 = 5, the firstplayer can remove 2 marbles from the second pile to maintain a balanceof the nim sum equation

12� 5� 9 = 0,

thereby securing a winning position.

Remarks. (1) This theorem indeed generalizes to an arbitrary number ofpiles.

(2) The Missere Nim game: Suppose now we change the rule: in theNim game, the player who makes the last move loses. Here is a winningstrategy: Play as for ordinary Nim, until you can move to a position inwhich all piles have just one marble.

6.2 The nim game 135

Exercise

In each of the following nime games, it is your turn to move. How wouldyou ensure a winning position?

(a) 3, 5, 7 marbles.(b) 9, 10, 12 marbles.(c) 1, 8, 9 marbles.(d) 1, 10, 12 marbles.

136 The nim game

Chapter 7

Fibonacci and Lucas numbers

7.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 0 1 2 3 4 5 6 7 8 9 10 11 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 byfinding their generating function, which is the formal power series

F (x) := F0 + F1x+ · · ·+ Fnxn + · · · .

From the defining relations, we have

F2x2 = F1x · x+ F0 · x2,

F3x3 = F2x

2 · x+ F1x · x2,

F4x4 = F3x

3 · x+ F2x2 · x2,

...

Fnxn = Fn−1x

n−1 · x+ Fn−2xn−2 · x2,

...

138 Fibonacci and Lucas numbers

Combining these relations we have

F (x)− (F0 + F1x) = (F (x)− F0) · x+ F (x) · x2,

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:

F (x) =x

1− x− x2.

There is a factorization of 1 − x − x2 by making use of the roots ofthe quadratic polynomial. Let α > β be the two roots. We have

α + β = 1, αβ = −1.

More explicitly,

α =

√5 + 1

2, β = −

√5− 1

2.

Now, since 1−x−x2 = (1−αx)(1−βx), we have a partial fractiondecomposition

x

1− x− x2=

x

(1− αx)(1− βx)=

1

α− β

(1

1− αx− 1

1− βx

).

Each of 11−αx

and 11−βx

has a simple power series expansion. In fact,making use of

1

1− x= 1 + x+ x2 + · · ·+ xn + · · · =

∞∑n=0

xn,

and noting that α− β =√5, we have

x

1− x− x2=

1√5

( ∞∑n=0

αnxn −∞∑n=0

βnxn

)

=∞∑n=0

αn − βn

√5

xn.

The coefficients of this power series are the Fibonacci numbers:

Fn =αn − βn

√5

, n = 0, 1, 2, . . . .

7.1 The Fibonacci sequence 139

1. Fn is the integer nearest to αn√5: Fn =

⟨αn√5

⟩.

Proof. ∣∣∣∣Fn − αn

√5

∣∣∣∣ =∣∣∣∣ βn

√5

∣∣∣∣ < 1√5<

1

2.

2. For n ≥ 2, Fn+1 = 〈αFn〉.Proof. Note that

Fn+1 − αFn =αβn − βn+1

√5

=α− β√

5· βn = βn.

For n ≥ 2,

|Fn+1 − αFn| = |β|n <1

2.

3. limn→∞Fn+1

Fn= α.

Exercise

1. (a) Make use of only the fact that 987 is a Fibonacci number toconfirm 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 Fibonaccinumber.

2. Prove by mathematical induction the Cassini formula:

Fn+1Fn−1 − F 2n = (−1)n.

3. The conversion from miles into kilometers can be neatly expressedby the Fibonacci numbers.

miles 5 8 13kilometers 8 13 21

How far does this go? Taking 1 meter as 39.37 inches, what is thelargest n for which Fn miles can be approximated by Fn+1 kilome-ters, correct to the nearest whole number?

140 Fibonacci and Lucas numbers

4. Prove the Fermat Last Theorem for Fibonacci numbers: there is nosolution of xn + yn = zn, n ≥ 2, in which x, y, z are (nonzero)Fibonacci numbers.

7.2 Some relations of Fibonacci numbers

1. Sum of consecutive Fibonacci numbers:n∑

k=1

Fk = Fn+2 − 1.

2. Sum of consecutive odd Fibonacci numbers:n∑

k=1

F2k−1 = F2n.

3. Sum of consecutive even Fibonacci numbers:n∑

k=1

F2k = F2n+1 − 1.

4. Sum of squares of consecutive Fibonacci numbers:

n∑k=1

F 2k = FnFn+1.

5. Cassini’s formula:

Fn+1Fn−1 − F 2n = (−1)n.

7.3 Zeckendorff representations 141

7.3 Zeckendorff representations

Every positive integer can be written uniquely as a sum of distinct Fi-bonacci numbers with no consecutive indices:

N = Fk1 + Fk2 + · · ·+ Fkm , ki > ki+1 + 1, i < m.

This is called the Zeckendorff representation of N .How do you find the Zeckendorff representation of 100000, knowing

that the largest Fibonacci summand is F30 = 832040.

Exercise

1. Prove that

F1 + F3 + · · ·+ F2k−1 =F2k − 1,

F2 + F4 + · · ·+ F2k =??

2. (a) Suppose Fibonacci had wanted to set up an annuity that wouldpay Fn lira on the nth year after the plan was established, for n =1, 2, 3, . . . (F1 = F2 = 1, Fn = Fn−1 + Fn−2 for n > 2). Tofund such an annuity, Fibonacci had planned to invest a sum ofmoney with the Bank of Pisa, which paid 70% interest per year,and instruct them to administer the trust. How much money did hehave to invest so that the annuity could last in perpetuity ?

(b) When he got to the bank, Fibonacci found that their interestrate was only 7% (he had misread their ads), not enough for hispurposes. Despondently, he went looking for another bank with ahigher interest rate. What rate must he seek in order to allow for aperpetual annuity ?

3. It is known that if Fn is a prime number, then n must be a primenumber. The converse is not true. In fact, the following Fibonaccinumbers are composites. Give a factorization of each of them:

p Fp Factorization

19 4181 37× 11331 134626937 2415781741 165580141

142 Fibonacci and Lucas numbers

7.4 The Lucas numbers

The sequence (Ln) satisfying

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 12Ln 1 3 4 7 11 18 29 47 76 123 199 322

Let α > β be the roots of the quadratic polynomial x2 − x− 1.

1. Ln = αn + βn.

2. Ln = Fn + 2Fn−1.

3. Ln+1 + Ln−1 = 5Fn.

4. F2k = L1L2L4L8 · · ·L2k−1 .

5. L1 = 1 and L3 = 4 are the only square Lucas numbers (U. Alfred,1964).

Exercise

1. Prove that L2n = L2n + 2(−1)n−1.

Solution.

L2n = α2n + β2n

= (αn + βn)2 − 2(αβ)n

= L2n − 2(−1)n.

2. Express F4n ÷ Fn in terms of Ln.

Solution.

F4n = F2nL2n = FnLnL2n = Fn(L3n + 2(−1)n−1Ln).

3. Express F3n ÷ Fn in terms of Ln.

Answer. F3n = Fn(L2n + (−1)n).

7.5 How can we know if a given integer is a Fibonacci number? 143

7.5 How can we know if a given integer is a Fibonaccinumber?

Theorem 7.1 (Gessel). An integer N is a Fibonacci number if and onlyif 5N2 ± 4 is a square.

Proof. Necessity: 5F 2n + 4(−1)n = L2

n.Sufficiency: If 5N2 + 4ε = M2 for ε = ±1 and an integer M , then

M +N√5

2· M −N

√5

2= ε = ±1,

and M+N√5

2is a unit in Q[

√5]. The units in Q[

√5] are ±αn for n ∈ Z.

Therefore,

M +N√5

2= αn =

(αn + βn) + (αn − βn)

2=

Ln + Fn

√5

2,

and N = Fn.

Remark. Ln = M , Fn−1 =M−N

2and Fn+1 =

M+N2

.

144 Fibonacci and Lucas numbers

7.6 Periodicity of Fibonacci sequence mod m

Let m > 1 be a given integer. We prove that the sequence (Fn (mod m))is periodic. Let fn = Fn (mod m). Since there are m2 − 1 possi-bilities for the pair (fn, fn+1), by the pigeonhole principle, there areh < k ≤ m2 such that (fh, fh+1) = (fk, fk+1). Let r be the least pos-itive integer such that (fh+r, fh+r+1) = (fh, fh+1) for some h. Tracingbackward, we have (fr, fr+1) = (f0, f1) = (0, 1). It follows that thesequence (fn) is periodic with period r.

m Fibonacci numbers modulo m period

2 0, 1, 1, 0, 1, . . . 3

3 0, 1, 1, 2, 0, 2, 2, 1, 0, 1, . . . 8

4 0, 1, 6

5 0, 1, 20

6 0, 1, 24

7 0, 1, 16

8 0, 1, 12

Exercise

Complete the table above and construct an arithmetic progression whichdoes not contain any Fibonacci number.

Chapter 8

Counting with Fibonaccinumbers

8.1 Squares and dominos

In how many ways can a 1 × n rectangle be tiled with unit squares anddominos (1× 2 squares)?

0 1 2 3 4 501

7 8 9 10111201

14151617181901

212223242526010 1 2 3 4 5

23

7 8 9 10111223

14151617181923

21222324252623

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 Fibonaccisequence, it follows that an = Fn+1 for every n ≥ 1.

146 Counting with Fibonacci numbers

8.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} isfat but B = {2, 4, 5} is not. Note that the empty set is fat. How many fatsubsets does [n] have?Solution. Suppose there are bn fat subsets of [n]. Clearly, b1 = 2 (everysubset is fat) and b2 = 3 (all subsets except [2] itself is fat). Here are the5 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, thenA = {n}. If m > 1, then every element of A is greater than 1. Thesubset

A′ := {j − 1 : j < n, j ∈ A}has m − 1 elements, each ≥ m − 1 since j ≥ m for every j ∈ A. Notethat A′ does not contain n − 1. It is a fat subset of [n − 2]. There arebn−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). Supposefor distinct a, b ∈ [n], π(a) = b. Prove that π(b) = a.

8.3 An arrangement of pennies 147

8.3 An arrangement of pennies

Consider arrangements of pennies in rows in which the pennies in anyrow are contiguous, and each penny not in the bottom row touches twopennies in the row below. For example, the first one is allowed but notthe 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 thebottom. Clearly

a1 = 1, a2 = 3, a3 = 5, a4 = 13.

A recurrence relation can be constructed by considering the numberof 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.

148 Counting with Fibonacci numbers

Here are some beginning values:

n an1 12 23 54 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∑

k=1

ak = F2n.

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∑k=1

ak = an+1 +n∑

k=1

ak

= F2n+1 + F2n

= F2(n+1).

Therefore, the conjecture is established for all positive integers n. Inparticular, an = F2n−1.

8.4 Counting circular permutations 149

8.4 Counting circular permutations

Let n ≥ 4. The numbers 1, 2, . . . , n are arranged in a circle. How manypermutations are there so that each number is not moved more than oneplace?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 suchcircular permutations.

For n = 4, this is L4 + 2 = 9.

4

1

2

3

4

1

2

3

4

1

2

3

4

2

1

3

4

1

2

3

4

1

3

2

4

1

2

3

1

2

3

4

4

1

2

3

1

4

2

3

4

1

2

3

1

4

3

2

4

1

2

3

3

4

1

2

4

1

2

3

3

1

2

4

4

1

2

3

3

2

1

4