Post Reply 
(32SII/DM32) Prime Factorization (edit)
11-17-2023, 03:41 AM (This post was last modified: 11-18-2023 03:36 PM by Eddie W. Shore.)
Post: #1
(32SII/DM32) Prime Factorization (edit)
Instructions:

1. Enter a positive integer on the X stack.
2. Run the program (XEQ P) and a prime factor is displayed. Press [ R/S ] to continue. At this point the calculator is set to FIX 0 mode. Repeat step 2.
3. The program ends when the integer reappears. The calculator is reset to FIX 4.

3 labels are needed.

Note: One instruction has been corrected, thank you, Thomas Klemm!

Code:
P01  LBL P
P02  FIX 0
P03  STO B
P04  STO A
P05  2
P06  STO F

B01  LBL B
B02  RCL A
B03  RCL÷ F
B04  ENTER
B05  FP
B06  x=0?
B07  GTO A
B08  1
B09  STO+ F
B10  GTO B

A01  LBL A
A02  RCL F
A03  STOP
A04  R↓
A05  R↓
A06  STO A
A07  1
A08  -
A09  x≠0?
A10 GTO B
A11 RCL B
A12 FIX 4
A13 RTN


Labels used: P, B, A
Variables: F (factor), A, B

Examples

26: 2, 13, 26 (26 = 2 × 13)

89: 89 (89 is prime)

175: 5, 5, 7, 175 (175 = 5^2 × 7)

1020: 2, 2, 3, 5, 17, 1020 (1020 = 2^2 × 3 × 5 × 17)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(32SII/DM32) Prime Factorization (edit) - Eddie W. Shore - 11-17-2023 03:41 AM



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