Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10107

Re: Trying to recursively define a double factorial

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Trying to recursively define a double factorial
Date 2012-05-17 08:12 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jp2bsj$4vh$1@smc.vnet.net> (permalink)
References <201205160820.EAA23026@smc.vnet.net>

Show all headers | View raw


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@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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Trying to recursively define a double factorial Murray Eisenberg <murray@math.umass.edu> - 2012-05-17 08:12 +0000

csiph-web