*The game of NIM*

**
I adapted this program for the HP41 from the original HP25 code found in a Gene Wright's page .
See instructions in that page.
**

**
**

Contents of NIM25.PRG --------------------- lbl 01 enter int abs x#y? gto 22 x=0? gto 22 4 xy x>y? gto 22 x=y? gto 22 rcl 01 + chs sto 01 x0? gto 46 x=0? gto 46 stop gto 25 lbl 22 rcl 00 sqrt gto 46 lbl 25 rcl 01 1 - x=0? gto 48 4 / int 4 * 1 + x=y? gto 40 gto 42 lbl 40 1 - lbl 42 chs sto 01 stop gto 01 lbl 46 rcl 03 rtn lbl 48 rcl 02 end

Also, before you execute NIM25.PRG you must put your first turn in X: 1, 2 or 3 are valid numbers for your first turn.

In the last adaptation I tried to maintain high compatibility with original HP25 code and I didn't include special HP41 commands.

Note: The right name of this game is NIM and isn't NIMB. You can find
interesting discussions about this game, for example, in:

"The Master Book of Mathematical Recreations" by Fred Schuh. (Dover Publications Inc., New
York, pages 144 to 154),

"Mathematical Recreations and Essays" by W.W. Rouse
Ball and H.S.M. Coxeter (Dover, pages 36 to 38),

"Mathematics and the Imagination" by Edward Kasner and James Newman (I have a Spanish
translation)

and several articles written by Martin Gardner for "Scientific
American".