The following warnings occurred:
Warning [2] Undefined array key 97032 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 97034 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 97040 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 97034 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 97040 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Permutation, Combination and Factoral for the 29C



#2

Hi Everybody.
Checking my son's homework the other night...statistics...I decided to throw a little program into my 29c that would crank out factoral, permutation and combination. After doing so, it dawned on me that the 29c/19c applications manual probably already has such a program in it, and such is indeed the case. To my (pleasant) surprise, however, the program in the applications manual is twice as long as mine (84 steps vs 42), and doesn't preserve the stack registers(y,z and t) when computing factorals, which mine does. (Note that machines with a hard coded factoral function also preserve y,z and t, safeguarding any intermediate results you may have sitting there.) Computation times are virtually the same as the program in the App manuel, with 69! taking about 27 seconds to compute. Smaller values of course take correspondingly less time, as with any purely iterative routine.

So, for what it's worth, here's the program listing.

Comments, suggestions, criticism...love to hear 'em.
Best regards, Hal


Directions:  key in total elements (m), Enter, key in subset (n). 	
For permutation, gsb 1
For combinations, gsb 2
Example: 20 objects total, how many arrangements of 5 can you make…20 enter 5 gsb 1. Result should be 1,860,480
Example: 20 objects total, how many combinations of 5 can you make…20 enter 5 gsb 2. Result should be 15,504
For x! (factoral) key in x, gsb 3
Example: find 8!…8 gsb 3. Result should be 40,320.
Note: Factoral subroutine preserves existing values in the y, z, and t registers
registers used: 0,5,6,7,8,9
labels used: 1,2,3,4

	HP 29C program:
1 lbl 2
2 sto 8
3 gsb 1
4 sto 9
5 rcl 8
6 rcl 8
7 gsb 1
8 rcl 9
9 x<>y
10 /
11 rtn
12 lbl 1
13 1
14 -
15 sto 0
16 x<>y
17 sto 7
18 sto 6
19 lbl 4
20 1
21 sto - 6
22 rcl 6
23 sto x 7
24 DSZ
25 gto 4
26 rcl 7
27 rtn
28 lbl 3
29 r dn
30 sto 5
31 r dn
32 sto 8
33 r dn
34 sto 9
35 r dn
36 enter^
37 gsb 1
38 rcl 9
39 scl 8
40 rcl 5
41 rcl 7
42 rtn


#3

Congrats!

Very good programming example. And a very good program itself, indeed.

Thanks for sharing.

Cheers.

Luiz (Brazil)

Edited: 31 July 2006, 12:07 a.m.

#4

For computing C(m,n), instead of computing P(m,n) and then dividing by n!,
it's better to rearrange the computation like this:

   C(m,n) = m / 1 * (m-1) / 2 * (m-2) / 3 ... * (m-n+1) / n

All the intermediate results will still be integers, and you avoid the overflow that would otherwise occur if P(m,n) is too large while C(m,n) is not.

- Thomas


Possibly Related Threads…
Thread Author Replies Views Last Post
  OT: Combination Lock for Calculators Katie Wasserman 45 9,208 09-03-2012, 05:30 PM
Last Post: Bart (UK)
  HP-29c keyboard dead 2nd row problem Xavier A. (Brazil) 6 2,201 07-17-2012, 07:09 AM
Last Post: Xavier A. (Brazil)
  HP-29C Counterparts Matt Agajanian 2 1,228 05-12-2012, 06:44 PM
Last Post: Matt Agajanian
  My 29C's even more bizarre behaviour Matt Agajanian 5 1,872 04-25-2012, 05:46 PM
Last Post: Matt Agajanian
  29C/25C question. Matt Agajanian 7 2,233 04-03-2012, 12:03 AM
Last Post: Matt Agajanian
  My very schizophrenic 29C Matt Agajanian 9 2,755 04-02-2012, 05:12 PM
Last Post: Matt Agajanian
  Help!! My 29C may need a doctor. Matt Agajanian 5 1,934 03-31-2012, 04:23 AM
Last Post: Ignazio Cara (Italy)
  Legible version of 29C Curve Fitting program Matt Agajanian 6 2,066 03-21-2012, 07:46 PM
Last Post: Matt Agajanian
  Sleek approach to Register Exchange on HP-29C Matt Agajanian 8 2,608 03-16-2012, 01:04 PM
Last Post: Marcus von Cube, Germany
  Is there a self-test program for the HP 25 or 29c ? Michael de Estrada 1 1,060 04-10-2011, 03:09 PM
Last Post: Xavier A. (Brazil)

Forum Jump: