for HP 42S
Factr - Factor a positive integer

Input
Resources to be used
Output

Program list
Factr - Rev.1.13 : Jul. 15 2010
 00 { 246-Byte Prgm }
 01>LBL "Factr"
 02 GTO 03

 03>LBL 00
 04 RCL+ 02 
 05 STO 02
 06 RCL 00
 07 X<>Y
 08 ÷
 09 FP
 10 X≠0?
 11 RTN 
 12 LASTX 
 13 STO 00
 14 SQRT
 15 IP
 16 STO 01
 17 XEQ D 
 18 CLX 
 19 GTO 00

 20>LBL 01
 21 4 
 22 XEQ 00
 23 2 
 24 XEQ 00
 25 4 
 26 XEQ 00
 27 2 
 28 XEQ 00
 29 4 
 30 XEQ 00
 31 6 
 32 XEQ 00
 33 2 
 34 XEQ 00
 35 6 
 36 XEQ 00
 37 RCL 00
 38 1 
 39 X=Y?
 40 GTO E 
 41 RCL 02
 42 RCL 01
 43 X>Y?
 44 GTO 01
 45 RCL 00
 46 STO 02
 47 XEQ D 
 48 GTO E 

 49>LBL 02
 50 STO 01
 51 1 
 52 ENTER 
 53 DIM "Factr"
 54 INDEX "Factr"
 55 STOIJ 
 56 LASTX 
 57 STOEL 
 58 CLX 
 59 STO 02
 60 2 
 61 XEQ 00
 62 1 
 63 XEQ 00
 64 2 
 65 XEQ 00
 66 2 
 67 XEQ 00
 68 RCL 00
 69 1 
 70 X≠Y?
 71 GTO 01
 72 GTO E 

 73>LBL 03
 74 ALL 
 75 CLA 
 76 AIP 
 77 ":"
 78 AVIEW 
 79 IP
 80 X≤0?
 81 GTO H 
 82 STO 00
 83 1E10
 84 X<>Y
 85 X≥Y?
 86 GTO H 
 87 ENTER 
 88 SQRT
 89 X≠Y?
 90 GTO 02
 91 STO 02
 92 XEQ D 
 93 GTO E 

 94>LBL D
 95 RCLIJ 
 96 1 
 97 + 
 98 DIM "Factr"
 99 STOIJ 
100 RCL 02
101 STOEL 
102 " "
103 AIP 
104 AVIEW 
105 RTN 

106>LBL E
107 "."
108 AVIEW 
109 RCLEL 
110 J+
111 RCLEL 
112 RCL "Factr"
113 RTN 

114>LBL H
115 "LFError"
116 AVIEW 
117 RTN 
118 END

SEE ALSO
A factorization algorithm written in C, which is used in the program shown above.
DOWNLOAD
'Factr-1.12' (factor.raw, 249 byte, raw program file for the Free42)

REFERENCE
"Factors and Primes for the HP-67", Hewlett-Packard
"Prime Number Factorisation for the HP-42S", Erik Ehrling
"Prime? for the HP 42s", Wanda Louise and BabyNous

www.finetune.co.jp [Mail] Copyright (c) HOSODA Takayuki. All rights reserved.
Powered by
 Finetune