Re: Trying to recursively define a double factorial
- To: mathgroup at smc.vnet.net
- Subject: [mg126529] Re: Trying to recursively define a double factorial
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Thu, 17 May 2012 04:10:12 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201205160820.EAA23026@smc.vnet.net>
- Reply-to: murray at math.umass.edu
You are defining the ordinary factorial function (which is already built in to Mathematica as Factorial). You don't need the ";/(n>0)" condition in your definition: Mathematica uses a special rule such as MyF1[1]=1 before it uses a general rule. So it would suffice to define: myF1[1] = 1; myF1[n_] := myF1[n] = n myF1[n-1] Note that I changed your capitalized function name to one that begins with a lower-case letter; since all built-in Mathematica names begin with capital letters, ordinarily a user's own names should not. Also -- a very minor point, there's no need for an explicit multiplication sign. On 5/16/12 4:20 AM, 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? > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Trying to recursively define a double factorial
- From: Jorge Cantu <monsterbone@msn.com>
- Trying to recursively define a double factorial