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


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

Re: Trying to recursively define a double factorial

Started byMurray Eisenberg <murray@math.umass.edu>
First post2012-05-17 08:12 +0000
Last post2012-05-17 08:12 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#10107 — Re: Trying to recursively define a double factorial

FromMurray Eisenberg <murray@math.umass.edu>
Date2012-05-17 08:12 +0000
SubjectRe: Trying to recursively define a double factorial
Message-ID<jp2bsj$4vh$1@smc.vnet.net>
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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web