Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

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.



  • Prev by Date: Re: Mathlink and packed arrays
  • Next by Date: postscript color trouble
  • Previous by thread: Re: sum of recursive fn: solving for n
  • Next by thread: Re: sum of recursive fn: solving for n