CH. i] ARITHMETICAL RECREATIONS 21 



remaining numbers to let him retain the possession of each 

 subsequent key number. The number of cards used, the points 

 on them, and the number to be reached can be changed at will ; 

 and the higher the number to be reached, the more difficult 

 it is to forecast the result and to say whether or not it is an 

 advantage to begin. 



Fourth Example. Here is another problem, more difficult 

 and less well known. Suppose that m counters are divided 

 into n heaps. Two players play alternately. Each, when his 

 turn comes, may select any one heap he likes, and remove from 

 it all the counters in it or as many of them as he pleases. 

 That player loses who has to take up the last counter. 



To solve it we may proceed thus*. Suppose there are a r 

 counters in the rth heap. Express a r in the binary scale, and 

 denote the coefficient of 2? in it by drp. Do this for each 

 heap, and let S p be the sum of the coefficients of 2? thus 

 determined. Thus S p = d\ p + d 2p + d sp + .... Then either S , 

 jS,, S iy ... are all even, which we may term an A arrangement, 

 or they are not all even, which we may term a B arrangement. 



It will be easily seen that if one player, P, has played so as 

 to get the counters in any A arrangement (except that of an 

 even number of heaps each containing one counter), he can 

 force a win. For the next move of his opponent, Q, must bring 

 the counters to a B arrangement. Then P can make the next 

 move to bring the counters again to an A arrangement, other 

 than the exceptional one of an even number of heaps each con- 

 taining only one counter. Finally this will leave P a winning 

 position, ex. gr. two heaps each containing 2 counters. 



If that player wins who takes the last counter, the rule is 

 similar. For if one player P has played so as to get the counters 

 in any A arrangement, including therein an even number of 

 heaps each containing one counter, he can force a win, since the 

 next move of his opponent Q must bring the counters to a B 

 arrangement. Then P can make the next move to bring the 

 counters again to an A arrangement. Finally this will leave 

 P a winning position. 



Fifth Example. The following medieval problem is somewhat 



* C. L. Bouton, Nim, Annals of Mathematics, Harvard, U.S.A., series 2, 

 vol. m, 1901—02, pp. 35—39. 



