Re: sum of recursive fn: solving for n

*To*: mathgroup at smc.vnet.net*Subject*: [mg22144] Re: sum of recursive fn: solving for n*From*: "P.J. Hinton" <paulh at wolfram.com>*Date*: Wed, 16 Feb 2000 02:35:07 -0500 (EST)*Organization*: "Wolfram Research, Inc."*References*: <888afd$c7p@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On 14 Feb 2000, AC fiona wrote: > what am i doing wrong here? > > f[x_] := (f[x-1])*2 > f[1] =2 > Solve[Sum[f[x], {x, 1,n}] ==62, n] You're doing the programmatic equivalent of beating a nail with a wrench. Try using recursion to solve your problem. In[1]:= n = 1; seedvalue = 2; summation = 2; NestWhile[ (n++; term = 2 #; summation += term; term) &, seedvalue, (#; summation < 62) & ] ; n Out[1]= 5 -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc. Disclaimer: Opinions expressed herein are those of the author alone.