Post Reply 
(15C) Prime Factorization
03-23-2017, 03:08 AM
Post: #1
(15C) Prime Factorization
This program does exactly this: factors an integer. Fix 0 mode is activated during execution. Each factor is displayed by pressing [R/S]. The calculator is returned to Fix 4 mode when the program is completed. If the integer is a prime number, the program just returns the integer entered.

Code:

Step    Key    Code
001    LBL B    42, 21, 22
002    FIX 0    42, 7, 0
003    STO 2    44, 2
004    STO 0    44, 0
005    2    2
006    STO 1    44, 1
007    LBL 3    42, 21, 3
008    RCL 0    45, 0
009    RCL÷ 1    45, 10, 1
010    ENTER    36
011    FRAC    42, 44
012    X=0    43, 20
013    GTO 2    22, 2
014    1    1
015    STO+ 1    44, 40, 1
016    GTO 3    22, 3
017    LBL 2    42, 21, 2
018    RCL 1    45, 1
019    R/S    31
020    R↓     33
021    R↓    33
022    STO 0    44, 0
023    1    1
024    -    30
025    X≠0    43, 30, 0  (TEST 0)
026    GTO 3    22, 3
027    LBL 2    45, 2
028    FIX 4    42, 7, 4  
029    RTN    43, 32
Example: 150. Factors: 2, 3, 5, 5 (when the display reads 150.0000 the factorization ends)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)