Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problems with recursive function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87389] Re: [mg87354] Problems with recursive function
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 9 Apr 2008 05:55:53 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

test[0, _] = 5;
test[a_Integer?Positive, b_] := test[a - 1, b]*b;

test[6, b]

5*b^6


Bob Hanlon

---- Frank Hechtner <frank.hechtner at rub.de> wrote: 
> Dear Newsgroup,
> 
> I'm in trouble with a recursive function. the functios looks similar to 
> test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an 
> argument of test.
> for any calculation i need to tell mathematica the first value of the 
> function, e.g. test[0, 5]=5. The problem is the following: the first 
> object is independent of b. does anyone know a way to tell mathematica 
> the following thing:
> 
>   test[0,b]=5 => test[0]=5 regardless to b.
> 
> Thanks for your help.
> 
> Frank
> 



  • Prev by Date: Re: Special Characters in Vista
  • Next by Date: Re: Bug in ExportString?
  • Previous by thread: Re: Problems with recursive function
  • Next by thread: Re: Problems with recursive function