HP 12C Permutation and Combination
|
08-16-2017, 09:12 PM
Post: #2
|
|||
|
|||
RE: HP 12C Permutation and Combination
(08-15-2017 04:54 AM)Gamo Wrote: To use it just start at GTO 00 for Permutation and GTO 10 for Combination. Very easy to remember to start at GTO 10 for Combination. Here is a version that implements an idea already posted in an earlier thread: have a common entry point (ideally line 00) and use a code number for different functions. Since C(n,k) simply is P(n,k) / k! this can be done in one common routine: Code: 01 STO 0 Usage: n [ENTER] k [ENTER] 0 [R/S] => P(n,k) n [ENTER] k [ENTER] 1 [R/S] => C(n,k) Instead of 1 any other value ≠ 0 may be used. Example: 25 [ENTER] 6 [ENTER] 0 [R/S] => 127512000 25 [ENTER] 6 [ENTER] 1 [R/S] => 177000 The first four lines store either 0 or 1 in R0, line 08 turns R0 into 0 or k, and after P(n,k) has been calculated it is divided by R0! (i.e. by 1 or by k!) to obtain the final result. The calculation of P(n,k) is done on the stack and requires no additional register. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)