#G03 INTEGERS 10 (2010), MIN, A COMBINATORIAL GAME HAVING A CONNECTION WITH PRIME NUMBERS

Similar documents
Slow k-nim. Vladimir Gurvich a

arxiv: v2 [math.co] 23 Mar 2012

Sprague-Grundy Values of the R-Wythoff Game

MATH4250 Game Theory 1. THE CHINESE UNIVERSITY OF HONG KONG Department of Mathematics MATH4250 Game Theory

Poset-Game Periodicity

ALGEBRA. 1. Some elementary number theory 1.1. Primes and divisibility. We denote the collection of integers

Section Summary. Proof by Cases Existence Proofs

arxiv: v1 [math.co] 27 Aug 2015

On tame, pet, domestic, and miserable impartial games

Impartial Games. Lemma: In any finite impartial game G, either Player 1 has a winning strategy, or Player 2 has.

Notes on Systems of Linear Congruences

Subtraction games. Chapter The Bachet game

Homework 3, solutions

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2

Geometrical extensions of Wythoff s game

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

NOTES ON SIMPLE NUMBER THEORY

arxiv: v2 [math.co] 9 Aug 2011

. As the binomial coefficients are integers we have that. 2 n(n 1).

Lecture 7 Feb 4, 14. Sections 1.7 and 1.8 Some problems from Sec 1.8

Chapter 5.1: Induction

PLAYING END-NIM WITH A MULLER TWIST

32 Divisibility Theory in Integral Domains

2. THE EUCLIDEAN ALGORITHM More ring essentials

MATH10040: Numbers and Functions Homework 1: Solutions

Announcements. Read Section 2.1 (Sets), 2.2 (Set Operations) and 5.1 (Mathematical Induction) Existence Proofs. Non-constructive

Writing Assignment 2 Student Sample Questions

Algebraic Structure in a Family of Nim-like Arrays

Lecture Notes. Advanced Discrete Structures COT S

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

The Euclidean Algorithm

MATH FINAL EXAM REVIEW HINTS

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

Ma/CS 6a Class 2: Congruences

Solutions to Practice Final 3

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

Wen An Liu College of Mathematics and Information Science, Henan Normal University, Xinxiang, P.R. China

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

Fibonacci Nim and a Full Characterization of Winning Moves

Carmen s Core Concepts (Math 135)

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

CS280, Spring 2004: Prelim Solutions

Ma/CS 6a Class 2: Congruences

Wilson s Theorem and Fermat s Little Theorem

Elementary Algebra Chinese Remainder Theorem Euclidean Algorithm

Number Theory and Graph Theory. Prime numbers and congruences.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

D-MATH Algebra I HS18 Prof. Rahul Pandharipande. Solution 1. Arithmetic, Zorn s Lemma.

7.2 Applications of Euler s and Fermat s Theorem.

NOTES ON INTEGERS. 1. Integers

On Aperiodic Subtraction Games with Bounded Nim Sequence

A sharp refinement of a result of Alon, Ben-Shimon and Krivelevich on bipartite graph vertex sequences

On the Sprague-Grundy function of exact k-nim

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

arxiv: v1 [math.co] 18 May 2018

MATH 2112/CSCI 2112, Discrete Structures I Winter 2007 Toby Kenney Homework Sheet 5 Hints & Model Solutions

1 Overview and revision

Elementary Properties of the Integers

Homework #2 solutions Due: June 15, 2012

Algebraic Structure in a Family of Nim-like Arrays

Discrete Math, Second Problem Set (June 24)

CISC-102 Fall 2017 Week 6

PROBLEM SET 1 SOLUTIONS 1287 = , 403 = , 78 = 13 6.

CHAPTER 1 REAL NUMBERS KEY POINTS

Fermat's Little Theorem

D. G. Horrocks 1 Department of Mathematics and Computer Science, University of Prince Edward Island, Charlottetown, PE C1A 4P3, Canada

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

Greedy Codes. Theodore Rice

FERMAT S LAST THEOREM FOR n = 3, NOTES FOR MATH In these notes, we prove Fermat s Last Theorem for n = 3.

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

1 Proof by Contradiction

(e) Commutativity: a b = b a. (f) Distributivity of times over plus: a (b + c) = a b + a c and (b + c) a = b a + c a.

Modular Arithmetic and Elementary Algebra

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

PRACTICE PROBLEMS: SET 1

Fundamentals of Pure Mathematics - Problem Sheet

7. Prime Numbers Part VI of PJE

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

Problems and Solutions

Math 3000 Section 003 Intro to Abstract Math Homework 6

A Family of Nim-Like Arrays: The Locator Theorem

Chapter 5. Number Theory. 5.1 Base b representations

CS 5319 Advanced Discrete Structure. Lecture 9: Introduction to Number Theory II

A misère-play -operator

11 Division Mod n, Linear Integer Equations, Random Numbers, The Fundamental Theorem of Arithmetic

All variables a, b, n, etc are integers unless otherwise stated. Each part of a problem is worth 5 points.

5: The Integers (An introduction to Number Theory)

Champion Spiders in the Game of Graph Nim

CISC-102 Winter 2016 Lecture 11 Greatest Common Divisor

PUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.

CHAPTER 3. Number Theory

Lecture 4: Number theory

Another bridge between Nim and Wythoff

Greatest Common Divisor MATH Greatest Common Divisor. Benjamin V.C. Collins, James A. Swenson MATH 2730

#A42 INTEGERS 10 (2010), ON THE ITERATION OF A FUNCTION RELATED TO EULER S

Single Pile (Move Size) Dynamic Blocking Nim

18 Divisibility. and 0 r < d. Lemma Let n,d Z with d 0. If n = qd+r = q d+r with 0 r,r < d, then q = q and r = r.

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Transcription:

#G03 INTEGERS 10 (2010), 765-770 MIN, A COMBINATORIAL GAME HAVING A CONNECTION WITH PRIME NUMBERS Grant Cairns Department of Mathematics, La Trobe University, Melbourne, Australia G.Cairns@latrobe.edu.au Nhan Bao Ho nbho@students.latrobe.edu.au, honhanbao@yahoo.com Received: 4/22/10, Accepted: 8/21/10, Published: 12/1/10 Abstract We introduce a two person game played with a pair of nonnegative integers; a move consists of subtracting from the larger integer, a positive integer no greater than the smaller integer. The player who reduces one of the integers to zero wins. The game is curious in several respects: in particular, its Sprague-Grundy values have an interesting connection with prime numbers. 1. Introduction We introduce a two person, impartial, combinatorial game, that we call min (short for minus). The game is played with an unordered pair of nonnegative integers. From position (a, b) with a b, a legal move consists of subtracting from b, a positive integer no greater than a. The first player who reduces one of the integers to zero wins. The game is a variation of nim, and it is related to Euclid, in which the players move by subtracting a positive integer multiple of the smaller integer from the larger integer; see references [1] to [6]. Actually, there are two versions of Euclid, according to whether one stops when the entries are equal, or one of them is reduced to 0. The latter case is the original game of Cole and Davie [2], while the former case was introduced by Grossman [4]. In both cases, there is an explicit formula for the Sprague-Grundy values. For Grossman s Euclid, Nivasch [5] gave the formula a b b a. For Cole and Davie s Euclid, the formula involves the continued fraction expansion of b/a; see [1]. For the game min the situation seems rather more complicated, and it is very unlikely that there is a simple formula for its Sprague-Grundy values, as will become apparent below. Let G(a, b) denote the Sprague-Grundy value of the position (a, b) in min. For convenience, throughout this paper we will refer to the Sprague-Grundy value simply as the nim-value. Recall that the nim-value of the terminal positions G(0, a) is zero, and that G(a, b) is the smallest nonnegative integer not contained in the set of nim-values of the positions that can be reached from (a, b). The game min

INTEGERS: 10 (2010) 766 is curious in three respects: 1. For a fixed and b a 1, the nim-values of positions G(a, b) are periodic in b with period a + 1. 2. The positions with nim-value 1 can be computed recursively without knowledge of the positions of the other nim-values. 3. There is an interesting connection with prime numbers. Our main result is the following: Theorem 1. For all a 1, we have G(a, a) = 1 if and only if a + 1 is prime. Calculations reveal a number of interesting patterns, which unfortunately die out for sufficiently large integers. For example, if G(a 1, a) = 0 and a < 6240, then a + 1 is prime. But G(a 1, a) = 0 for a = 6240, and here a + 1 = 79 2, which is not prime. Similarly, there are only 4 values of a with G(a 2, a) = 0 and a < 17226; in these cases, the values of a + 1 are the first 4 Fermat primes: 3, 5, 17, 257. However, G(17224, 17226) = 0, and 17227 isn t a Fermat prime. 2. Preliminaries Remark 2. Note that for a > 0, we have G(a, a) 0, since G(0, a) = 0 and there is a move from (a, a) to (a, 0). Moreover, by induction, G(1, a) = 0 if and only if a is even. We begin by showing that for fixed a > 0, the number G(a, b) is periodic in b with period a + 1, provided b is sufficiently large. For integers x, y with y > 0, we denote the remainder R y (x) = x y x/y, where denotes the integer part. Lemma 3. Suppose that a 1. (a) If b 2a, then G(a, b) = G(a, a 1 + R a+1 (b a + 1)). (b) If b a 1, then {G(a, b), G(a, b + 1),..., G(a, b + a)} = {0, 1,..., a}. Proof. We prove (b) first. Note that if 0 j < k a, then there is a move from (a, b + k) to (a, b + j) and so the elements G(a, b), G(a, b + 1),..., G(a, b + a)

INTEGERS: 10 (2010) 767 are all distinct. Furthermore, if a b and 0 i a, or a = b + 1 and 0 < i, there are exactly a moves from the position (a, b + i), while if a = b + 1 and i = 0, there are a 1 moves from (a, b + i). Therefore G(a, b + i) a for all 0 i a. This gives the required result. From (b) we have {G(a, b + 1), G(a, b + 2),..., G(a, b + a + 1)} = {0, 1,..., a} = {G(a, b), G(a, b + 1),..., G(a, b + a)}. Hence G(a, b + a + 1) = G(a, b), which gives (a). In general, it is not true that G(a, b + a + 1) = G(a, b) for b < a 1. However, there are partial results. Let f j (a) be the smallest nonnegative integer i such that G(a, a + i) = j. Note that by the previous lemma, 0 f j (a) a. Lemma 4. Suppose that a > 0. Then (a) G(a, f 0 (a) 1) = 0. (b) If f 1 (a) > 0, then G(a, f 1 (a) 1) = 1. Proof. (a) First note that by Remark 2, we have f 0 (a) > 0. There are exactly a moves from G(a, a + f 0 (a)), which lead respectively to (a, f 0 (a)), (a, f 0 (a) + 1),..., (a, a + f 0 (a) 1), so none of these positions has nim-value 0. Suppose that G(a, f 0 (a) 1) 0. Then none of the positions (a, f 0 (a) 1), (a, f 0 (a)),..., (a, a + f 0 (a) 2) would have nim-value 0, and so we would have G(a, a + f 0 (a) 1) = 0, where f 0 (a) 1 is nonnegative, contrary to the definition of f 0 (a). (b) Similarly, there are exactly a moves from G(a, a + f 1 (a)), leading respectively to (a, f 1 (a)), (a, f 1 (a) + 1),..., (a, a + f 1 (a) 1), so none of these positions has nim-value 1. Suppose that G(a, f 1 (a) 1) 1. Then none of the positions (a, f 1 (a) 1), (a, f 1 (a)),..., (a, a + f 1 (a) 2) would have nim-value 1, and so we would have G(a, a + f 1 (a) 1) 1. We have already observed that (a, a + f 1 (a) 1) does not have nim-value 1. So G(a, a + f 1 (a) 1) = 0. As f 1 (a) > 0, we have a + f 1 (a) 1 a. In fact, as

INTEGERS: 10 (2010) 768 G(a, a + f 1 (a) 1) = 0 and G(a, a) 0 by Remark 1, we have a + f 1 (a) 1 > a; that is, f 1 (a) 2. As the nim-values {G(a, a), G(a, a + 1),..., G(a, 2a)} are distinct, by Lemma 3(b), f 0 (a) = f 1 (a) 1. Thus, by part (a) of the current lemma, G(a, f 1 (a) 2) = 0. Consider the positions (a, f 1 (a) 2), (a, f 1 (a) 1),..., (a, a + f 1 (a) 3). None of these positions has nim-value 1, and one of them, (a, f 1 (a) 2), has nim-value 0. Hence (a, a + f 1 (a) 2) has nim-value 1, in contradiction with the definition of f 1 (a). Remark 5. Note that for all a, one has G(a, a + 1) 1. Indeed, if G(a, a + 1) = 1, then we would have f 1 (a) = 1 and so by Lemma 4(b), G(a, 0) = 1, which is false. Thus, if f 1 (a) > 0, then f 1 (a) 2. Lemma 6. For j = 0, 1, if f j (a) > 0, then f j (f j (a) 1) = R fj(a)(a + 1). Proof. We have f j (a) 1 < a. By Lemma 4, G(a, f j (a) 1) = j. Hence, by Lemma 3(a), a (f j (a) 1) f j (f j (a) 1) (mod f j (a)). Thus a + 1 f j (f j (a) 1) (mod f j (a)). Lemma 7. Let a 1. If G(a, a) 1, then gcd(f 1 (a), a + 1) > 1. Proof. The proof is by induction on a. The condition holds for a = 1, since G(1, 1) = 1. Fix a > 1 and suppose the condition holds for all b < a. Assume that G(a, a) 1. Then f 1 (a) 2 by Remark 2. Let b = f 1 (a) 1. By Lemma 6, f 1 (b) = R f1(a)(a+1). Note that if f 1 (b) = 0, then a + 1 is a multiple of f 1 (a), which gives the required result. So we suppose that f 1 (b) 0. By the inductive hypothesis, gcd(f 1 (b), b + 1) > 1. Let us denote λ = gcd(f 1 (b), b + 1). So λ divides f 1 (b) and b + 1 = f 1 (a). Therefore, λ also divides a + 1, since f 1 (b) = R f1(a)(a + 1). Hence λ also divides gcd(f 1 (a), a + 1), which gives us the required result. 3. Proof of the Theorem We first establish the following result. Lemma 8. Suppose that 1 a b. (a) If G(a, b) = 0, then gcd(a + 1, b + 1) = 1. (b) If G(a, b) = 1, then gcd(a + 1, b + 1) is a prime number. (c) If a + 1 is prime, then G(a, b) = 1 iff a + 1 is a factor of b + 1.

INTEGERS: 10 (2010) 769 Proof. The proof is by induction on a. Note that all three parts of the lemma are true for a = 1, by Remark 2. (a) Suppose G(a, b) = 0. So a < b, by Remark 2. We have b = k (a+1)+r a+1 (b) for some integer k 1. So by Lemma 3, G(a, a + 1 + R a+1 (b)) = G(a, b) = 0. So by Lemma 4, G(a, R a+1 (b)) = 0. Note that R a+1 (b) a. In fact, since G(a, R a+1 (b)) = 0 and G(a, a) 0 by Remark 2, we have R a+1 (b) < a. Hence, by the inductive hypothesis, gcd(a + 1, R a+1 (b) + 1) = 1. Therefore, gcd(a + 1, b + 1) = 1. (b) Now suppose that G(a, b) = 1. First consider the case where a = b. Then none of the positions (a, i), for 0 i < a have nim-value 1. Let p be a prime less than a and consider the position (a, p 1). By part (c) of the inductive hypothesis, since p is prime and G(a, p 1) 1, we have that p is not a factor of a + 1. Thus a + 1 is not a multiple of any prime less than a. Therefore, a + 1 is prime; that is, gcd(a + 1, a + 1) is prime. Now we treat the case where a < b. By Lemma 4, we have G(a, R a+1 (b)) = 1. Hence, by the inductive hypothesis, gcd(a + 1, R a+1 (b) + 1) is prime. Since gcd(a + 1, b + 1) = gcd(a + 1, R a+1 (b) + 1), this gives the required result. (c) Assume that a+1 is prime. If G(a, b) = 1, then by part (b), gcd(a+1, b+1) = a + 1, so a + 1 is a factor of b + 1. Conversely, if a + 1 is a factor of b + 1, then G(a, b) = G(a, a) by Lemma 3. So it remains to show that G(a, a) = 1. By Lemma 7, if G(a, a) 1, then gcd(f 1 (a), a + 1) > 1, which, as a + 1 is prime, would imply that a + 1 is a factor of f 1 (a). But this is impossible as f 1 (a) a, by definition. Finally, we deduce the theorem. First, if G(a, a) = 1, then a+1 = gcd(a+1, a+1) is a prime number, by part (b) of the previous lemma. Conversely, if a + 1 is prime, then by part (c) of the previous lemma, G(a, a) = 1. 4. Computational Considerations Notice that knowledge of the function f 1 enables one to decide whether a given position has nim-value 1. Indeed, given position (a, b), one can use Lemma 3(a) to reduce to the case where a b 2a. Since there is only one position in this range with nim-value 1, by Lemma 3(b), it remains to check whether f 1 (a) = b a. The function f 1 can be computed recursively, as we will now explain. If a + 1 is prime, then f 1 (a) = 0, by the theorem. Otherwise, f 1 (a) > 0 and G(a, f 1 (a) 1) = 1, by Lemma 4(b). There may be several positions of nim-value 1 of the form (a, c) with 0 c < a. The key point is that f 1 (a) 1 is the largest of these

INTEGERS: 10 (2010) 770 c values; indeed, as (a, a + f 1 (a)) has nim-value 1, none of the positions (a, f 1 (a)), (a, f 1 (a) + 1),..., (a, a + f 1 (a) 1) has nim-value 1. So, assuming f 1 (x) is known for x < a, we compute f 1 (a) as follows. Consider the successive positions (a, a i), for i = 1, 2, 3,... Proceed until a position (a, a i) is found with nim-value 1; as explained above, this is done by checking whether f 1 (a i) = R a i+1 (i). Then, f 1 (a) = a i + 1. In this manner, the positions with nim-value 1 can be computed without knowledge of the positions of the other nim-values. By using Lemma 4(a), the positions with nim-value 0 can be determined separately, in the same manner. References [1] Grant Cairns and Nhan Bao Ho, The Sprague-Grundy function of the real game Euclid, preprint. [2] A. J. Cole and A. J. T. Davie, A game based on the Euclidean algorithm and a winning strategy for it, Math. Gaz. 53 (1969), 354-357. [3] David Collins, Variations on a theme of Euclid, Integers 5 (2005), no. 1, G3, 12 pp. (electronic). [4] J. W. Grossman, A nim-type game, problem #1537, Math. Mag. 70 (1997), 382. [5] Gabriel Nivasch, The Sprague-Grundy function of the game Euclid, Discrete Math. 306 (2006), no. 21, 2798-2800. [6] Edward L. Spitznagel, Jr., Properties of a game based on Euclid s algorithm, Math. Mag. 46 (1973), 87-92.