The Museum of HP Calculators


NIM for the HP-35S

This program is by Paul Dale and is used here by permission.

This program is supplied without representation or warranty of any kind. Paul Dale and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

This program plays the classic game of NIM.

To run it, enter the number in the pile and press XEQ N ENTER. You and the calculator will take turns taking from 1 to 3 from the pile, whoever takes the last one loses. You know it is your turn when the pile's remaining count is displayed negative.

After you turn, the new pile count will display followed by the calculator's grab count.

Listing

N001  LBL N
N002  STO S
N003  FS? 10
N004  GTO N008
N005  XEQ N008
N006  CF 10
N007  RTN
N008  STO O
N009  SF 10
N010  4
N011  STO I
N012  ALL
N013  GTO N016
N014  eqn ERROR
N015  PSE
N016  RCL O
N017  +/-
N018  STO N
N019  INPUT N
N020  RCL N
N021  INTG
N022  x<=0?
N023  GTO N014
N024  RCL I
N025  x<=y?
N026  GTO N014
N027  x<>y
N028  STO- O
N029  RCL O
N030  x<=0?
N031  GTO N040
N032  2
N033  x<=y?
N034  GTO N043
N035  eqn I LOSE
N036  PSE
N037  CLSTK
N038  RCL S
N039  RTN
N040  eqn I WIN!
N041  PSE
N042  GTO N037
N043  RCL O
N044  STO N
N045  VIEW N
N046  PSE
N047  1
N048  -
N049  RCL/ I
N050  FP
N051  RCL* I
N052  x<>0?
N053  GTO N062
N054  RANDOM
N055  RCL I
N056  1
N057  -
N058  *
N059  1
N060  +
N061  INTG
N062  STO- O
N063  STO T
N064  VIEW T
N065  PSE
N066  GTO N016

Go back to the software library
Go back to the main exhibit hall