HP 12C: Prime
Factoring (by Don Shepard)
Introduction – Cash
Flow Registers to Simulate Indirect Addressing
This program uses what is called indirect addressing on the
HP 12C, which can be simulated by the use of the cash flow registers.
Cash flow registers can be registered by using the cash flow
[ g ] [PMT] (CFj) and frequency [ g ] [
FV ] (Nj) registers. Every time a cash
flow is stored, the counter is increased by 1.
The counter can be recalled by press [RCL] [ n ].
Similarly, you can recall the cash flows by the use of [RCL]
[ g ] [PMT] (CFj) and the attached frequencies by the use of [RCL] [ g ] [ FV ]
(Nj). Each time a cash flow is recalled,
the counter is decreased by 1.
Each cash flow can have a frequency up to 99 copies.
Fun fact: the first 20
cash flows can be stored into registers R0 through R19, with the 20th flow
stored in FV (future value). The cash
flow 0 is the initial cash flow, CF0 (accessed by [ g ] [ PV ] (CF0)).
This is kind of storing values in a list and recalling them whenever
necessary.
Program:
Enter the integer and press [ R/S ]. Keep pressing [ R/S ] to reveal more
factors. The factorization ends when a
zero appears.
(Remember if you
program using a HP 12C Platinum, step numbers are three digits instead of two.)
Step

Code

Key

01

44, 0

STO 0

02

42, 32

Clear Σ

03

2

2

04

44, 11

STO n

05

6

6

06

43, 14

[ g ] CFj

07

2

2

08

43, 15

[ g ] Nj

09

6

6

10

43, 14

[ g ] CFj

11

4

4

12

43, 15

[ g ] Nj

13

2

2

14

43, 14

[ g ] CFj

15

4

4

16

43, 15

[ g ] Nj

17

2

2

18

43, 14

[ g ] CFj

19

4

4

20

43, 15

[ g ] Nj

21

2

2

22

43, 14

[ g ] CFj

23

43, 15

[ g ] Nj

24

1

1

25

43, 14

[ g ] CFj

26

2

2

27

43, 15

[ g ] Nj

28

0

0

29

44, 12

STO i

30

45, 43, 15

RCL [ g ] Nj

31

43, 33, 56

GTO 56

32

1

1

33

44, 12

STO i

34

45, 43, 14

RCL [ g ] CFj

35

43, 33, 56

GTO 56

36

45, 11

RCL n

37

3

3

38

43, 34

x≤y

39

43, 33, 28

GTO 28

40

45, 0

RCL 0

41

43, 23

LN

42

43, 35

x=0

43

43, 33, 00

GTO 00

44

6

6

45

44, 11

STO n

46

45, 0

RCL 0

47

45, 1

RCL 1

48

36

ENTER

49

20

*

50

43, 34

x≤y

51

43, 33, 28

GTO 28

52

45, 0

RCL 0

53

31

R/S

54

0

0

55

43, 33, 00

GTO 00

56

44, 40, 1

STO+ 1

57

45, 0

RCL 0

58

45, 1

RCL 1

59

10

÷

60

43, 24

FRAC

61

43, 35

x=0

62

43, 33, 67

GTO 67

63

45, 12

RCL i

64

43, 35

x=0

65

43, 33, 32

GTO 32

66

43, 33, 36

GTO 36

67

45, 1

RCL 1

68

44, 10, 0

STO÷ 0

69

31

R/S

70

0

0

71

43, 33, 56

GTO 56

** Line 34 has been corrected. 10/3/2017
Example 1:
Factoring 148:
148 [R/S]
Display: 2, Press
[R/S]
Display: 2, Press
[R/S]
Display: 37, Press
[R/S]
Display: 0
Result: 148 = 2 * 2 *
37 = 2^2 * 37
Example 2:
Factoring 976:
976
Display: 2, Press
[R/S]
Display: 2, Press
[R/S]
Display: 2, Press
[R/S]
Display: 2, Press
[R/S]
Display: 61, Press
[R/S]
Display: 0, Press
[R/S]
Result: 976 = 2 * 2 *
2 * 2 * 61 = 2^4 * 61
Special thanks to Don Shephard for letting me post his
program on this blog. Shepard attended
HHC 2017, where he spoke about punch cards and their history.
Eddie
This blog is property
of Edward Shore, 2017.
This Prime Factor program that used the Cash Flow register is very powerful one.
ReplyDeleteI try this method compare to other method and this one by far is very fast. By using the buildin functions integrated into the program make this HP 12C the fastest computation speed compare to other similar models like HP 15C.
The other excellent program that use the cash flow functions with NPV and IRR is Polynomial Equation.
The fibonaccicalculator is a tool that traders use to help identify strategic places for transactions, stop losses or target prices to help them get in at a good price.
ReplyDelete