Re: Trying to recursively define a double factorial

• To: mathgroup at smc.vnet.net
• Subject: [mg126528] Re: Trying to recursively define a double factorial
• From: Peter Breitfeld <phbrf at t-online.de>
• Date: Thu, 17 May 2012 04:09:51 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <jovo6m\$mhq\$1@smc.vnet.net>

```Jorge Cantu wrote:

> My goal here is to define a recursive function for a double factorial.  The domain of this function is the set of positive integers.  For a positive even integer  n  the value DF[n] is the product of all positive even integers which are  <n.  For a positive odd integer   n   the value DF[n] is the product of all positive odd integers which are <n.
>
> I wanna make a recursive function of this double factorial without If(and other similar statements). Here is my work so far:
>
>
> Clear[MyF1, n];
> MyF1[1] = 1;
> MyF1[n_Integer] /; (n > 0) := MyF1[n] = n*MyF1[n - 1]
>
> Table[MyF1[k], {k, (*integer*), (*integer*)}]
>
>
>
>                How do I do this?
>

This should work:
Clear[myF]
myF[-1] = 1
myF[0] = 1
myF[1] = 1;
myF[n_Integer?Positive] := myF[n] = n myF[n - 2]

Compare with build in !!:

Table[{myF[k], k!!}, {k, 1, 10}]

Output:
{{1, 1}, {2, 2}, {3, 3}, {8, 8}, {15, 15}, {48, 48}, {105, 105}, {384,
384}, {945, 945}, {3840, 3840}}

--
_________________________________________________________________
Peter Breitfeld | Bad Saulgau, Germany | http://www.pBreitfeld.de

```

• Prev by Date: Re: Trying to recursively define a double factorial
• Next by Date: Re: Trying to recursively define a double factorial
• Previous by thread: Re: Trying to recursively define a double factorial
• Next by thread: Re: Trying to recursively define a double factorial