Wednesday, March 22, 2017

HP 15C: Prime Factorization



HP 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.  

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*
RCL 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)
 
* Thanks to Ross Barnes to pointing the typo to me.  The key is now correct.  - Eddie 11/13/2021

This blog is property of Edward Shore, 2017.

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode The Probability Simulation add-in has six type...