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 endYou need to enter the values 55178 in memory 03, 3507.1 in memory 02, -1 in memory 00 and (important!): -15 in memory 01. Don't forget to set the display mode to FIX 0.
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".