04-14-2020, 01:19 PM

DIM: (Syntax: rows, cols, DIM) Sets the initial dimensions of the matrix.

INDEX: Sets the index pointer to I = 1 and J = 1.

GROW: Sets the HP 42S to grow mode. This allows the matrix to build additional rows and columns by adding new elements.

J+: Does one of two things in Grow Mode. It either moves the pointer to the next column or creates a new row. For a matrix with only 1 column as its initial dimension, J+ creates a new row automatically.

Matrix: 1 to N

The first program, nLIST generates a one column matrix from 1 to n.

LBL 00: Main Loop

LBL 01: Adds another row

LBL 02: End of program and shows the resulting matrix, MATD in edit mode

R01: counter variable counting from n (in X stack) to 1

HP 42S/Free 42S/DM42 Program: nLIST

Example: 8 nLIST returns

[[ 8 ]

[ 7 ]

[ 6 ]

[ 5 ]

[ 4 ]

[ 3 ]

[ 2 ]

[ 1 ]]

Press the soft keys ( ↑ ) and ( ↓ ) to scroll throw the matrix. Press [EXIT] to exit the matrix. The matrix MATD is stored as a stack element.

Simulating HP Prime's idivis Command

The program IDIVIS simulates the IDIVIS command on the HP Prime. IDIVIS lists all the divisors of an integer ( n ).

LBL 00: Main Loop - tests for divisors

LBL 01: Adds any divisors and creates another row

LBL 02: Decreases the counter variable

LBL 03: Trims the excessive row by the DELR (delete row) command, ends the program and shows the resulting matrix, MATD in edit mode

R00: n

R01: counter variable counting from n (in X stack) to 1. The program stops when R01 reaches 0 (it is skipped thanks to the DSE command).

R02 = R00/R01

HP 42S/Free 42S/DM42S Program: IDIVIS

Examples

45 (IDIVIS) returns 1, 3, 5, 9, 15, 45 (press ↓ to reveal the next row in MATD)

27 (IDIVIS) returns 1, 3, 9, 27

53 (IDIVIS) returns 1, 53

INDEX: Sets the index pointer to I = 1 and J = 1.

GROW: Sets the HP 42S to grow mode. This allows the matrix to build additional rows and columns by adding new elements.

J+: Does one of two things in Grow Mode. It either moves the pointer to the next column or creates a new row. For a matrix with only 1 column as its initial dimension, J+ creates a new row automatically.

Matrix: 1 to N

The first program, nLIST generates a one column matrix from 1 to n.

LBL 00: Main Loop

LBL 01: Adds another row

LBL 02: End of program and shows the resulting matrix, MATD in edit mode

R01: counter variable counting from n (in X stack) to 1

HP 42S/Free 42S/DM42 Program: nLIST

Code:

00 { 50-Byte Prgm }

01▸LBL "nLIST"

02 STO 01

03 1

04 1

05 DIM "MATD"

06 INDEX "MATD"

07 GROW

08▸LBL 00

09 RCL 01

10 STOEL

11 DSE 01

12 GTO 01

13 GTO 02

14▸LBL 01

15 J+

16 GTO 00

17▸LBL 02

18 EDITN "MATD"

19 END

[[ 8 ]

[ 7 ]

[ 6 ]

[ 5 ]

[ 4 ]

[ 3 ]

[ 2 ]

[ 1 ]]

Press the soft keys ( ↑ ) and ( ↓ ) to scroll throw the matrix. Press [EXIT] to exit the matrix. The matrix MATD is stored as a stack element.

Simulating HP Prime's idivis Command

The program IDIVIS simulates the IDIVIS command on the HP Prime. IDIVIS lists all the divisors of an integer ( n ).

LBL 00: Main Loop - tests for divisors

LBL 01: Adds any divisors and creates another row

LBL 02: Decreases the counter variable

LBL 03: Trims the excessive row by the DELR (delete row) command, ends the program and shows the resulting matrix, MATD in edit mode

R00: n

R01: counter variable counting from n (in X stack) to 1. The program stops when R01 reaches 0 (it is skipped thanks to the DSE command).

R02 = R00/R01

HP 42S/Free 42S/DM42S Program: IDIVIS

Code:

00 { 64-Byte Prgm }

01▸LBL "IDIVIS"

02 STO 00

03 STO 01

04 1

05 1

06 DIM "MATD"

07 INDEX "MATD"

08 GROW

09▸LBL 00

10 RCL 00

11 RCL÷ 01

12 STO 02

13 FP

14 X=0?

15 GTO 01

16 GTO 02

17▸LBL 01

18 RCL 02

19 STOEL

20 J+

21▸LBL 02

22 DSE 01

23 GTO 00

24 GTO 03

25▸LBL 03

26 DELR

27 EDITN "MATD"

28 .END.

Examples

45 (IDIVIS) returns 1, 3, 5, 9, 15, 45 (press ↓ to reveal the next row in MATD)

27 (IDIVIS) returns 1, 3, 9, 27

53 (IDIVIS) returns 1, 53