Skip to content

Factorial2 ​

The double factorial n!!n!!, the product of every second integer from n down to 1 or 2.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaDouble factorialMathWorldDoubleFactorialWikidataQ13520655nLabdouble factorialFungrimDoubleFactorialFungrim entrya68f0eb6b014OEISA006882Wolfram LanguageFactorial2✓
Factorial2(n)the double factorial n!!n!!.
SageMathInteger(n).multifactorial(2)SymPyfactorial2(n)mpmathfac2(n)JuliaCombinatorics.doublefactorial(big(n))
Typed signatures
TypePackageApplies
(complex | infinity) -> numberanalyticreplaces compute-enginealways
(complex | infinity) -> numbercompute-enginealways
(any) -> anynumber-theoryreplaces analyticalways

Domain: Combinatorics

Details
  • Skips every other factor: n!!=n(n−2)(n−4)⋯n!! = n(n-2)(n-4)\cdots, stopping at 1 (n odd) or 2 (n even).
  • Recurrence: n!!=n (n−2)!!n!! = n\,(n-2)!!, with 0!!=10!! = 1.
  • Splits an ordinary factorial into its even and odd parts: n!=n!! (n−1)!!n! = n!!\,(n-1)!!.
  • (2n−1)!!(2n-1)!! counts the perfect matchings of 2n2n objects into pairs.
  • The recurrence run downwards extends it to negative odd integers, (−2k−1)!!=(−1)k(2k−1)!!(-2k-1)!! = \dfrac{(-1)^k}{(2k-1)!!}; at negative even integers it hits a pole (a division by the 0!!0!! term) and returns NaN.

Examples

Basic #

7 × 5 × 3 × 1

live ↗
In7!!7!!Out105105

8 × 6 × 4 × 2

live ↗
In8!!8!!Out384384
live ↗
In10!!10!!Out3 8403\,840
live ↗
In0!!0!!Out11
live ↗
In20!!20!!Out3 715 891 2003\,715\,891\,200

The recurrence n!!=n⋅(n−2)!!n!! = n \cdot (n-2)!! run downwards extends it to negative odd integers: (−1)!!=1(-1)!! = 1, (−3)!!=−1(-3)!! = -1, (−5)!!=13(-5)!! = \frac{1}{3}

live ↗
In(−1)!!(-1)!!Out11

Threads element-wise over a list

live ↗
In[1,2,3,4,5]!!\bigl\lbrack1, 2, 3, 4, 5\bigr\rbrack!!Out[1,2,3,8,15]\bigl\lbrack1, 2, 3, 8, 15\bigr\rbrack

Negative odd integers follow the recurrence backwards: (−3)!!=−1(-3)!! = -1

live ↗
In(−3)!!(-3)!!Out−1-1

(−5)!!=13(-5)!! = \frac{1}{3} by the backward recurrence

live ↗
In(−5)!!(-5)!!Out13\frac{1}{3}

Real arguments use the analytic continuation 2(1+2x−cos⁡πx)/4 π(cos⁡πx−1)/4 Γ(1+x2)2^{(1+2x-\cos\pi x)/4}\,\pi^{(\cos\pi x-1)/4}\,\Gamma(1+\frac{x}{2})

live ↗
In2.5!!2.5!!Out2.407 069 456 116 0442.407\,069\,456\,116\,044

The number of ways to pair up 10 people into 5 couples: (2n−1)!!(2n-1)!! counts perfect matchings of 2n2n objects

live ↗
In9!!9!!Out945945

Splits an ordinary factorial into even and odd parts: n!=n!! (n−1)!!n! = n!!\,(n-1)!!

live ↗
In8!=8!!×7!!8!=8!!×7!!OutTrue\mathrm{True}

Even double factorials: (2n)!!=2n n!(2n)!! = 2^n\,n!

live ↗
In10!!=25×5!10!!=2^5×5!OutTrue\mathrm{True}

Odd double factorials: (2n−1)!!=(2n)!2n n!(2n-1)!! = \frac{(2n)!}{2^n\,n!}

live ↗
In9!!=10!25×5!9!!=\frac{10!}{2^5×5!}OutTrue\mathrm{True}

Negative even arguments hit a pole in the recurrence, so compute-engine returns ComplexInfinity

live ↗
In(−2)!!(-2)!!Out∞~\tilde∞

15!!=2,027,02515!! = 2{,}027{,}025, already past two million despite skipping every other factor

live ↗
In15!!15!!Out2 027 0252\,027\,025
Possible issues #

$(-\infty)!! $ — the trig-based analytic continuation isn't defined at ±∞\pm\infty; native declines cleanly to Indeterminate

live ↗
In−∞!!-∞!!OutIndeterminate⁡\operatorname{Indeterminate}
About
Examples17
Checked againstWolfram Language 17 agreeSageMath 14 agree3 errorSymPy 14 agree3 errormpmath 16 agree1 errormathlib4 10 agree6 errorJulia 11 agree6 error
CrosswalkWikipediaMathWorldWikidatanLabFungrimFungrim entry ×2OEISWolfram LanguageSageMathSymPympmathJulia

Implementation

mappedsympypackages/oracle/src/mappings.ts
mappedmpmathpackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedmathlib4packages/oracle/src/mappings.ts

Nat.doubleFactorial n, n!! with 0!! = 1!! = 1; natural n only, so the negative odd extension (-1)!! = 1, (-3)!! = -1 is out of its domain.

See also: Factorial