(33C) (33E) C(y,x), P(y,x) and x!
|
05-07-2018, 06:36 PM
(This post was last modified: 05-07-2018 06:44 PM by Rogier.)
Post: #1
|
|||
|
|||
(33C) (33E) C(y,x), P(y,x) and x!
The 33E was (is) my first programmable calculator. Limited in capacity compared to most other HP-programmables, but you can still fit quite a lot in 49 steps + jumps and subroutines.
HP supplies solutions programs for C(y,x) and P(y,x), but these are bulky. This program calculates C(y,x), P(y,x) and x! in 43 lines. USE: y ENTER x R/S > C(y,x) X<=>Y P(y,x) 0 ENTER x R/S > x! NOTE: - x and y must be 0 or positive integers - x<y - y-x must not exceed 69 - y can be >69. E.g. the program can calculate C(100,50) and P(100,50). Just try. Code:
Registers used: 0 Total 1 Subtotal 2 Y 3 X 4 Y-X WORKING: Line 01-06 sort out the special cases; - (y,0) [> GTO 38, display 1 and stop] or - (0,x) [GTO 41, call the x! routine (27) and stop. This may seem unnecessarily complicated but the 33C/E interprets Rtn without preceding GSB as R/S, not as GTO 00 like I want.] After this the program calculates C(y,x) = y!/[(x!)(y-x)!] then it multiplies C(y,x) by x! to get P(y,x). (I could swap calculation of P(y,x) and C(y,x), but then I can't use y!/x! And that is what enables the program tot function with y>69). Lines 27 ... 37 form the main loop. This loop is set to terminate on y-x (to speed up calculation of y!/x!), or on 0 (to calculate x!) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(33C) (33E) C(y,x), P(y,x) and x! - Rogier - 05-07-2018 06:36 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Dieter - 05-07-2018, 08:46 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Rogier - 05-09-2018, 06:43 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Dieter - 05-09-2018, 08:35 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Rogier - 05-10-2018, 12:38 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Dieter - 05-10-2018, 01:32 PM
RE: (33C) (33E) C(y,x), P(y,x) and x! - Rogier - 05-10-2018, 05:48 PM
|
User(s) browsing this thread: 1 Guest(s)