*The Museum of HP Calculators*

#
Prime? for the HP 42s

This program was written by Wanda Louise &
BabyNous and is used
here by permission.

This program is supplied without representation or warranty of any kind.
The author 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

The Program assumes that there is already a Real Matrix, of any Dimensions,
already in Memory called: Prime.

**Input:** X: Real Number

**Running Output:** LUFRN: > CD

Where:

LUFRN is the Lowest UnFactored Real Number

CD is the Countdown (SQRT(Current Real) - current
factor)

**Terminal Output:**

X: [ 1x? Matrix ]

1:1= Original Real

1:->= Prime Factors

##
The Program

LINE KEYS
00 { 252-Byte Prgm }
01 LBL "Prm?"
02 STO "CREAL"
03 SQRT
04 STO "SQRTCR"
05 2
06 STO "CFACT"
07 1
08 STO "SZPRIME"
09 1
10 DIM "Prime"
11 INDEX "Prime"
12 STOIJ
13 RCL "CREAL"
14 STOEL
15 LBL a
16 CLA
17 ARCL "CREAL"
18 ?": > "
19 RCL "SQRTCR"
20 ENTER
21 RCL "CFACT"
22 -
23 IP
24 ARCL ST X
25 AVIEW
26 RCL "SQRTCR"
27 RCL "CFACT"
28 X>Y?
29 GTO e
30 XEQ A
31 RCL "CFACT"
32 2
33 X=Y?
34 GTO 01
35 2
36 GTO 00
37 LBL 01
38 1
39 LBL 00
40 STO+ "CFACT"
41 GTO a
42 LBL e
43 RCL "SZPRIME"
44 1
45 X!=Y?
46 GTO c
47 "Prime!!!"
48 AVIEW
49 GTO J
50 LBL c
51 "Composite!!!"
52 AVIEW
53 RCL "CREAL"
54 1
55 X=Y?
56 GTO J
57 1
58 STO+ "SZPRIME"
59 RCL "SZPRIME"
60 DIM "Prime"
61 STOIJ
62 RCL "CREAL"
63 STOEL
64 LBL J
65 CLST
66 RCL "Prime"
67 CLV "SZPRIME"
68 CLV "CFACT"
69 CLV "CREAL"
70 CLV "SQRTCR"
71 STOP
72 LBL A
73 RCL "CREAL"
74 RCL "CFACT"
75 ÷
76 ENTER
77 FP
78 X!=Y?
79 GTO B
80 roll dn
81 STO "CREAL"
82 SQRT
83 STO "SQRTCR"
84 1
85 STO+ "SZPRIME"
86 RCL "SZPRIME"
87 DIM "Prime"
88 STOIJ
89 RCL "CFACT"
90 STOEL
91 XEQ A
92 LBL B
93 RTN
94 END

##
Variables

CREAL: Current Real
SQRTCR: SQRT(CREAL)
CFACT: Current Factor
SZPRIME: Size of Prime
Prime: Final Matrix

Go back to the
software library

Go back to
the main exhibit hall