HP Forums
(30b) Fermat's Factorization Prog - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (30b) Fermat's Factorization Prog (/thread-2379.html)



(30b) Fermat's Factorization Prog - Gerald H - 11-02-2014 01:48 PM

Fermat’s factorization finds the largest factor less or equal to the square root of integer input:

0 P6
1 Input
2 Input
3 STO 1
4 √
5 Math
6 Up
7 Up
8 Input
9 Input
10 2
11 *
12 1
13 STO 2
14 +
15 STO 3
16 R↓
17 X^2
18 Swap
19 -
20 STO 4
21 Lbl 10
22 RCL 4
23 GT 11
24 RCL 2
25 STO- 3
26 2
27 STO/ 3
28 RCL 1
29 RCL 3
30 RTN
31 Lbl 11
32 RCL 3
33 STO+ 4
34 2
35 STO+ 3
36 Lbl 12
37 RCL 2
38 STO- 4
39 2
40 STO+ 2
41 RCL 4
42 0
43 ?>
44 GT 12
45 Gto 10

Improvement suggestions welcome.