Post Reply 
WP 34S: Shanks' Square Form Factorization Programme
05-23-2014, 05:45 AM
Post: #1
WP 34S: Shanks' Square Form Factorization Programme
Shanks' square form factorization finds a factor for composite integer input N.

If the continued fraction expansion is too short the programme stops with the message "Elliptic" displayed - in this case N can be multiplied by a small odd factor, eg 3, 5, 7.... & factorization again attempted.

The command "FND" is an attempt to reproduce the HP 42S hidden commend "[FIND]".

Improvements & bug reports welcome.

1 LBL 'SQF'
2 DBLOFF
3 GTO 07
4 LBL 04
5 CLα
6 α'Ell'
7 α'ipt'
8 α'ic'
9 RCL 08
10 VIEWα
11 RTN
12 LBL 01
13 RCL 08
14 RCL+ X
15 LBL 07
16 CLREGS
17 STO 08
18 ENTER
19 √
20 IP
21 STO 04
22 STO 02
23 x^2
24 -
25 x=0?
26 GTO 00
27 STO 03
28 x=1?
29 GTO 01
30 # 010
31 STO 09
32 CF 00
33 # 008
34 RCL* 02
35 √
36 IP
37 STO 05
38 LBL 03
39 RCL 05
40 RCL 03
41 ODD?
42 SKIP 002
43 # 002
44 /
45 x>? Y
46 GTO 06
47 STO→ 09
48 ISG 09
49 LBL 06
50 RCL 02
51 ENTER
52 RCL+ 04
53 RCL 03
54 MOD
55 -
56 STO 04
57 x^2
58 +/-
59 RCL+ 08
60 RCL/ 03
61 STO 03
62 ENTER
63 √
64 FS?C 00
65 GTO 03
66 SF 00
67 FP
68 x≠0?
69 GTO 03
70 1
71 RCL L
72 x=? Y
73 GTO 04
74 STO 06
75 XEQ 'FND'
76 x=1?
77 GTO 03
78 RCL 06
79 RCL 02
80 RCL- 04
81 RCL X
82 RCL 06
83 MOD
84 -
85 RCL+ 04
86 LBL 02
87 RCL 08
88 RCL Y
89 x^2
90 -
91 RCL/ 06
92 STO 06
93 RCL 02
94 RCL+ Z
95 x<>Y
96 MOD
97 +/-
98 RCL+ 02
99 x≠? Y
100 GTO 02
101 RCL 06
102 ODD?
103 RTN
104 # 002
105 /
106 RTN
107 LBL 00
108 RCL 04
109 RTN
110 LBL 'FND'
111 1
112 0
113 .
114 3
115 0
116 0
117 1
118 XEQ 'MFD'
119 # 040
120 x>? Y
121 SKIP 002
122 # 000
123 RTN
124 # 001
125 END
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: