Post Reply 
Double factorial
03-02-2015, 04:18 PM
Post: #2
RE: Double factorial
(03-02-2015 01:49 PM)salvomic Wrote:  hi all,
how it 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

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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Double factorial - salvomic - 03-02-2015, 01:49 PM
RE: Double factorial - Han - 03-02-2015 04:18 PM
RE: Double factorial - Helge Gabert - 03-02-2015, 04:36 PM
RE: Double factorial - salvomic - 03-02-2015, 05:15 PM
RE: Double factorial - Gerald H - 03-02-2015, 05:30 PM
RE: Double factorial - salvomic - 03-02-2015, 05:32 PM
RE: Double factorial - DrD - 03-03-2015, 12:02 PM
RE: Double factorial - salvomic - 03-03-2015, 01:24 PM



User(s) browsing this thread: 1 Guest(s)