Double factorial
|
03-02-2015, 01:49 PM
(This post was last modified: 03-02-2015 05:28 PM by salvomic.)
Post: #1
|
|||
|
|||
Double factorial
hi all,
how is a simple (and precise) way to define a command to calculate the "double factorial" (see here) with Prime? I mean to use it as a simple command. We cannot write n!!, as that is not the same... thank you, Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
03-02-2015, 04:18 PM
Post: #2
|
|||
|
|||
RE: Double factorial
(03-02-2015 01:49 PM)salvomic Wrote: hi all, The wiki explains how you can calculate it using the regular factorial: If \( n \) is even, then there exists some integer \( k \) such that \( n = 2k \). \[ n!! = n(n-2)(n-4) \dotsm 4 \cdot 2 = (2k)(2k-2)(2k-4)\dotsm (2\cdot 2) \cdot (2\cdot 1) = 2^k k! \] If \( n \) is odd, then there exists some integer \( k \) such that \( n = 2k+1 \). Moreover, \( n-1 \) is even. \[ n!! = \frac{\text{product of all integers from 1 to } n}{\text{product of all even integers from 2 to } n-1} = \frac{n(n-1)(n-2)\dotsm 3 \cdot 2 \cdot 1}{ (n-1)(n-3)(n-5)\dotsm 4 \cdot 2} = \frac{n!}{(n-1)!!} = \frac{(2k+1)!}{2^k k!} \] It should be pretty easy to write your own program using these formulas. (Note: the wiki has a slight error with respect to the formula for odd values of \(n \) ) Graph 3D | QPI | SolveSys |
|||
03-02-2015, 04:36 PM
Post: #3
|
|||
|
|||
RE: Double factorial
No error checking, but something along these lines
#cas DFA(n):= BEGIN IF odd(n) THEN product(n,n,1,n,2); ELSE product(n,n,2,n,2); END; END; #end Is this what you are asking (simple program)? |
|||
03-02-2015, 05:15 PM
Post: #4
|
|||
|
|||
RE: Double factorial
(03-02-2015 04:18 PM)Han Wrote: The wiki explains how you can calculate it using the regular factorial: (03-02-2015 04:36 PM)Helge Gabert Wrote: No error checking, but something along these lines yes, thanks both! so this should be enough "precise" and it is ok both in Home and CAS: Code:
My memory failed, and I didn't remember "product()" thanks again, Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
03-02-2015, 05:30 PM
Post: #5
|
|||
|
|||
RE: Double factorial
An assist from the 50G side:
:: CK1&Dispatch BINT1 :: COERCEDUP BINT2 #/ DUP FPTR2 ^#FACT Z2_ ROT FPTR2 ^PPow# FPTR2 ^RMULText SWAP #0=case SWAPDROP SWAP FPTR2 ^#FACT FPTR2 ^SWAPRDIV ; ; |
|||
03-02-2015, 05:32 PM
Post: #6
|
|||
|
|||
RE: Double factorial
(03-02-2015 05:30 PM)Gerald H Wrote: An assist from the 50G side: thanks! 50g is always a great Calc! ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
03-03-2015, 12:02 PM
Post: #7
|
|||
|
|||
RE: Double factorial
Here is a slight variation on your theme:
Code:
-Dale- |
|||
03-03-2015, 01:24 PM
Post: #8
|
|||
|
|||
RE: Double factorial
(03-03-2015 12:02 PM)DrD Wrote: Here is a slight variation on your theme: nice, Dale, thanks! ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
03-03-2015, 06:15 PM
Post: #9
|
|||
|
|||
RE: Double factorial
(03-02-2015 05:03 PM)compsystems Wrote: Please HP´ TEAM can include product operator in the next version of ROM, or at least that on the historial, the product command is displayed as an operator... I agree. ∏, Productoria (or, Italian, Produttoria) as operator, a part of the command product: it would be very useful also. Tim, do you think that it's possible to do it? Thank you. Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)