for HP 15C
Factr - Factor a positive integer

Input
Resources to be used
Output

Program list
Note: Press [RCL][E] in USER mode to view the results.
Factr - Rev.1.15 : Nov. 22, 2012 - use matrix to save results
001-42,21,15 
002-   43 44 
003-   44 .2 
004-42,16, 0 
005-       2 
006-      36 
007-       1 
008-42,23,15 
009-42,16, 1
010-   45 .2 
011u   44 15 
012-      11 
013-   44 .3 
014-   43 35 
015-   44 .4 
016-       2 
017-   32  7 
018-       1 
019-   32  7 
020-       2 
021-   32  7 
022-       2 
023-   32  7 
024-   45 .2 
025-       1 
026-43,30, 5 
027-   22  6 
028-42,21, 9 
029-       4 
030-   32  7 
031-       2 
032-   32  7 
033-       4 
034-   32  7 
035-       2 
036-   32  7 
037-       4 
038-   32  7 
039-       6 
040-   32  7 
041-       2 
042-   32  7 
043-       6 
044-   32  7 
045-   45 .2 
046-       1 
047-43,30, 5 
048-   22  6 
049-   45 .4 
050-   45 .3 
051-43,30, 7 
052-   22, 9 
053-   45, 2 
054-   44, 4 
055-   32  8 
056-42,21, 6 
057-42,16, 1 
058-45,16,15 
059-   43 32 
060-42,21, 7 
061-45,40,.4 
062-   44,.4 
063-   45,.2 
064-      34 
065-      10 
066-   42 44 
067-43,30, 0 
068-   43 32 
069-   43 36 
070-   44 .2 
071-      11 
072-   43 44 
073-   44 .3 
074-   45 .4 
075-   32  8 
076-   43 35 
077-   22  7 
078-42,21, 8 
079-      31 
080-45,23,15 
081-      40 
082-       1 
083-42,23,15 
084-      30 
085-   44  0 
086-      33 
087u   44 15 
088-   43 32 

 LBL E       ; entry point 
 IP
 STO .2      ; current number 
 MATRIX 0    ; clear matrix 
 2
 ENTER
 1
 DIM E       ; make 2x1 matrix 
 MATRIX 1    ; r0 = r1 = 1 
 RCL .2
 STO E       ; number to factor
 SQRT
 STO .3
 CLX
 STO .4
 2           ; 2 
 GSB 7
 1           ; 3 
 GSB 7
 2           ; 5 
 GSB 7
 2           ; 7 
 GSB 7
 RCL .2
 1
 TEST 5      ; X=Y? 
 GTO 6
 LBL 9
 4           ; 11 
 GSB 7
 2           ; 13 
 GSB 7
 4           ; 17 
 GSB 7
 2           ; 19 
 GSB 7
 4           ; 23 
 GSB 7
 6           ; 29 
 GSB 7
 2           ; 31 
 GSB 7
 6           ; 37 
 GSB 7
 RCL .2
 1
 TEST 5      ; X=Y? 
 GTO 6
 RCL .4
 RCL .3      ; upper bound
 TEST 7      ; X>Y?
 GTO 9       ; for next 30 
 RCL .2
 STO .4
 GSB 8
 LBL 6
 MATRIX 1    ; r0 = r1 = 1
 RCL MATRIX E
 RTN
 LBL 7
 RCL+ .4
 STO .4
 RCL .2
 X<>Y
 ÷
 FRAC
 TEST 0      ; X≠0? 
 RTN
 LASTX
 STO .2
 SQRT
 INT
 STO .3
 RCL .4
 GSB 8
 CLX
 GTO 7
 LBL 8
 R/S        ; R/S to continue
 RCL DIM E
 +
 1
 DIM E
 -
 STO 0
 R↓
 STO E      ; in USER mode
 RTN

Note: Press [R/S] at every factorization to continue.
Factr(s)- Rev.1.14: Oct. 4, 2012 - without saving results
001-42,21,15 
002-   43 44 
003-   44  0 
004-      11 
005-   44  1 
006-   43 35 
007-   44 25 
008-       2 
009-   32  7 
010-       1 
011-   32  7 
012-       2 
013-   32  7 
014-       2 
015-   32  7 
016-   45  0 
017-       1 
018-43,30, 5 
019-   43 32 
020-42,21, 9 
021-       4 
022-   32  7 
023-       2 
024-   32  7 
025-       4 
026-   32  7 
027-       2 
028-   32  7 
029-       4 
030-   32  7 
031-       6 
032-   32  7 
033-       2 
034-   32  7 
035-       6 
036-   32  7 
037-   45  0 
038-       1 
039-43,30, 5 
040-   43 32 
041-   45 25 
042-   45  1 
043-43,30, 7 
044-   22, 9 
045-   45  0 
046-   44 25 
047-   43 32 
048-42,21, 7 
049-45,40,25 
050-   44 25 
051-   45  0 
052-      34 
053-      10 
054-   42 44 
055-43,30, 0 
056-   43 32 
057-   43 36 
058-   44  0 
059-      11 
060-   43 44 
061-   44  1 
062-   45 25 
063-      31 
064-   43 35 
065-   22  7 

 LBL E       ; entry point 
 IP
 STO 0       ; current number 
 SQRT
 STO 1       ; upper bound 
 CLX         ; 0 
 STO I
 2           ; 2 
 GSB 7
 1           ; 3 
 GSB 7
 2           ; 5 
 GSB 7
 2           ; 7 
 GSB 7
 RCL 0
 1
 TEST 5      ; X=Y? 
 RTN
 LBL 9
 4           ; 11 
 GSB 7
 2           ; 13 
 GSB 7
 4           ; 17 
 GSB 7
 2           ; 19 
 GSB 7
 4           ; 23 
 GSB 7
 6           ; 29 
 GSB 7
 2           ; 31 
 GSB 7
 6           ; 37 
 GSB 7
 RCL 0
 1
 TEST 5      ; X=Y? 
 RTN
 RCL I
 RCL 1       ; upper bound
 TEST 7      ; X>Y?
 GTO 9       ; for next 30 
 RCL 0
 STO I
 RTN
 LBL 7
 RCL+ I
 STO I
 RCL 0
 X<>Y
 ÷
 FRAC
 TEST 0      ; X≠0? 
 RTN
 LASTX
 STO 0
 SQRT
 INT
 STO 1
 RCL I
 R/S
 CLX
 GTO 7

Rev.1.15 : Nov. 22, 2012
Rev.1.14 : Oct. 4, 2012
Rev.1.13 : Jul. 16, 2010
SEE ALSO
A factorization algorithm written in C, which is used in the program shown above.
factr - integer factorization program for the HP-42S
HP 15C - LC resonator replacement for triple speed 15C

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] © 2000 Takayuki HOSODA.
Powered by
 Finetune