The Museum of HP Calculators

HP Forum Archive 17

 HP-9G programming bugMessage #1 Posted by Xerxes on 28 May 2007, 9:54 a.m. I tried to program the N-Queens Problem on the HP-9G for benchmarking and get a "NEST Er" without a plausible reason. After invastigating the problem, I have found the following: ```N=3 S=0 Lbl 0: S=S+N IF(--N)THEN{GOTO 0} PRINT S ``` This simple program for the sum of 1..n works only to N=3. The reason seems to be the jump out of the IF block more than 3 times. Is it possible to avoid this problem?

 Re: HP-9G programming bugMessage #2 Posted by Raymond Del Tondo on 28 May 2007, 11:12 a.m.,in response to message #1 by Xerxes Hi, did you try other variable names? Did you try with discrete operations, like N=N-1 instead of '(--N)' ? What does the doc say about that 'GOTO 0' construct ? Or about the error message? A nesting error indicates that either calling the subprogram would exceed the the allowed nesting depth, or maybe you forgot the correct return statement. Raymond

 Re: HP-9G programming bugMessage #3 Posted by Xerxes on 28 May 2007, 11:43 a.m.,in response to message #2 by Raymond Del Tondo I have tried N=N-1 or other variables too. The "NEST Er" is discribed in the manual for the GOSUB statement with a maximum of 3 nesting depth. Another example: ```N=0 Lbl 0: IF(1)THEN{N=N+1} GOTO 0 ``` ```N=0 Lbl0: IF(1)THEN{N=N+1;GOTO 0} ``` The first example works but the second gives a "NEST Er".

Go back to the main exhibit hall