(42S) Dynamic Matrices and List of Divisors
|
04-14-2020, 01:19 PM
Post: #1
|
|||
|
|||
(42S) Dynamic Matrices and List of Divisors
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 Code:
[[ 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:
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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)