HP 42S User Manual

Page 22

Advertising
background image

works normally and if not the program jumps one line. The X?Y functions work in the same way
but now the condition is about the lines x and y of the stack and not only about line x.

Example: A kind of “timer”

01 LBL A
02 1
03 -
04 X=0?
05 STOP (Enter R/S)
06 GTO A
07 RTN

In this program you first enter a big integer number and then press XEQ “A”. The program will
subtract 1 from this number until get zero. Of course the bigger the number the bigger the time the
program will spend. The Emu42 program (yes, I use it too) in my laptop using “Authentic
Calculator Speed” option takes about 37s for the number 1000. Without this option or using Free42
is too much faster!

6.4 Real program examples.

Here is one of my favorite programs. It just see if a number is prime. (With a small change works in
33S too)

01 LBL “PRIME”
02 STO 00
03 2
04 STO 01
05 MOD (Rmdr in HP-33S)
06 X=0?
07 GTO F
08 3
09 STO 01
10 RCL 00
11 SQRT
12 STO 02
13 LBL B
14 RCL 00
15 RCL 01
16 MOD
17 X=0?
18 GTO F
19 2
20 STO + 01
21 RCL 02
22 RCL 01
23 X≤Y?
24 GTO B
25 RCL 00
26 STO 01
27 LBL F
28 RCL 01
29 RTN

Advertising