HP 42S manual Real program examples, LBL Prime, Sqrt

Page 22

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

021

03-

04X=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)

06X=0?

07GTO F

083

09STO 01

10RCL 00

11SQRT

12STO 02

13LBL B

14RCL 00

15RCL 01

16MOD

17X=0?

18GTO F

192

20STO + 01

21RCL 02

22RCL 01

23X≤Y?

24GTO B

25RCL 00

26STO 01

27LBL F

28RCL 01

29RTN

Image 22
Contents An alternative HP-42S/Free42 Manual Version 2005 Index Introduction Basic Operations RPNTraining RPN using HP-42S Setting the display contrastTurn ON/OFF Menus FIX, SCI, ENG, ALL, RDX., RDXPage Modes Menu StackGetting used to some keys of the keyboard Page Abcde Fghi Jklm Nopq Rstuv Wxyz Memory Catalog menu More on the Clear menuAssign FCN ABS Custom menuAssign ABS to Where N!=N.N-1.N-2...2.1 ProbabilityPage Complex numbers in rectangular coordinates Complex NumbersComplex numbers in polar coordinates Programming Basic programming19STOP More than one program in the memory Enter X?0 and X?Y sub-menusLBL Prime Real program examplesSqrt Using the Solver Select Solve ProgramPage Numeric Integration Ba f  xdxEnter 6 Σ+ StatisticsSub-menu Cfit Second line ALLΣ, LINΣ, Σreg and ΣRG? Functions Matrices Enter Matrix NEW = BEnter 3 NEW Edit 1 Enter →→5 +/- Enter Exit STO B Enter NEW Enter ComplexMatrix 1 Enter 3 NEW RCL a RCL B Matrix CrossOther Bases Flags License