(12C) Permutation & Combination revisit
|
07-28-2024, 04:29 PM
(This post was last modified: 08-07-2024 05:38 PM by C.Ret.)
Post: #3
|
|||
|
|||
RE: (12C) Permutation & Combination revisit
Dear friends,
These codes are interesting, but they are actually two codes in one. If we are allowed to use a memory register and without changing the way we enter \(n\) and \(k\) in the stack, it is possible to make a shorter code. Indeed \( P(n,k) = \frac{n!}{(n-k)!}\) and \(C(n,k)=\frac{n!}{(n-k)! \cdot k!}\) thus \(C(n,k)=\frac{P(n,k)}{k!}\). The idea is that instead of typing a GTO xx to start the calculation of the combinations from scratch, it is enough to press R/S when the number of Permutations \(P(n,k)\) is displayed to continue and terminate the computation of the Combinaisons \(C(n,k)\). So I propose the following code: Code: 01- 44 0 STO 0 P.S.: It is possible to save an instruction by changing the way \(n\) and \(k\) are entered in the stack (but this make a lot of R/S - this version is the easier to use. Usage: Permutations: Restart from start : [ f ] [ Prgm ] Enter \(n\) and \(k\) : n [ENTER] k Press [R/S] to run the code and get the # of permutations \(P(n,k)\) Combinaisons: Restart from start : [ f ] [ Prgm ] Enter \(n\) and \(k\) : n [ENTER] k Press [R/S] to run the code and press [R/S] a second time when Permutations are displayed to get the # of Combinaisons \(C(n,k)\). Example: 8P3 + 6C3 - 5P3 = ? 8 [ f ][ PRGM ] 3 [R/S] display 336 6 [ f ][ PRGM ] 3 [R/S] display 120 [R/S] display 20 [+] display 356 5 [ f ][ PRGM ] 3 [R/S] display 60 [-] display answer 296. EDIT: 24-AOUT-07 Typo in key-codes of RCL 0. Mnemonic Rdn replace by R↓ see folling posts. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C) Permutation & Combination revisit - Gamo - 07-25-2024, 08:36 AM
RE: (12C) Permutation & Combination revisit - Thomas Klemm - 07-28-2024, 10:57 AM
RE: (12C) Permutation & Combination revisit - C.Ret - 07-28-2024 04:29 PM
RE: (12C) Permutation & Combination revisit - AnnoyedOne - 08-04-2024, 03:09 PM
RE: (12C) Permutation & Combination revisit - C.Ret - 08-07-2024, 05:32 PM
RE: (12C) Permutation & Combination revisit - AnnoyedOne - 08-07-2024, 05:49 PM
RE: (12C) Permutation & Combination revisit - Matt Agajanian - 07-28-2024, 05:57 PM
|
User(s) browsing this thread: 2 Guest(s)