05-18-2015, 06:10 PM
In an attempt to rival Doom for the largest number of systems to which it's been ported, here's the usual HP 67 "mod 30" prime factors program for the 41C/CV/CX.
Enter a positive integer, and XEQ FCTR. Press R/S to view each factor. Zero will be displayed when there are no more factors.
Note this is a pretty straight port, and hasn't been fancied up with any 41-specific capabilities (yet).
EDIT: Here's a slightly improved version with a couple optimizations, and multiplicity display for factors (e.g. 3^2, 7^3, etc).
Enter a positive integer, and XEQ FCTR. Press R/S to view each factor. Zero will be displayed when there are no more factors.
Note this is a pretty straight port, and hasn't been fancied up with any 41-specific capabilities (yet).
EDIT: Here's a slightly improved version with a couple optimizations, and multiplicity display for factors (e.g. 3^2, 7^3, etc).
Code:
01 LBL FCTR
02 CF 05
03 FIX 0
04 STO 00
05 SQRT
06 STO 01
07 0
08 STO 02
09 STO 03
10 2
11 XEQ 02
12 1
13 XEQ 02
14 2
15 XEQ 02
16 2
17 XEQ 02
18 RCL 00
19 1
20 X=Y?
21 GTO 09
22 LBL 01
23 4
24 XEQ 02
25 2
26 XEQ 02
27 4
28 XEQ 02
29 2
30 XEQ 02
31 4
32 XEQ 02
33 6
34 XEQ 02
35 2
36 XEQ 02
37 6
38 XEQ 02
39 RCL 00
40 1
41 X=Y?
42 GTO 09
43 RCL 01
44 RCL 02
45 X<=Y?
46 GTO 01
47 RCL 00
48 STO 02
49 0
50 XEQ 02
51 GTO 09
52 LBL 02
53 ST+ 02
54 RCL 00
55 RCL 02
56 MOD
57 X!=0?
58 GTO 05
59 LBL 03
60 RCL 02
61 ST/ 00
62 RCL 00
63 SQRT
64 STO 01
65 1
66 ST+ 03
67 SF 05
68 0
69 GTO 02
70 LBL 05
71 FC?C 05
72 RTN
73 RCL 03
74 RCL 02
75 CLA
76 ARCL X
77 |-^
78 ARCL Y
79 0
80 STO 03
81 PROMPT
82 RTN
83 LBL 09
84 CLX
85 RTN
86 END