Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

Re: NestWhile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32556] Re: NestWhile
  • From: Erich Neuwirth <erich.neuwirth at univie.ac.at>
  • Date: Sat, 26 Jan 2002 04:08:37 -0500 (EST)
  • References: <a2r3ih$9m8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

NestWhileList[f, 9, # != 1 &]


Tom De Vries wrote:
> 
> Hello!
> 
> I know this is a simple question, hope someone can help me out.....
> 
> If I define the function
> 
> f[n_] := If[EvenQ[n], n/2, 3n + 1]
> 
> I can then apply NestList and generate a nice number loop......
> 
> NestList[f, 7, 23]
> 
> I want to use NestWhileList and stop when the generated number is a 1.  How
> do I do that?
> 
> Thanks for the help,
> 
> Sincerely,
> 
> Tom De Vries

--
Erich Neuwirth, Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386


  • Prev by Date: Headless set of elements?
  • Next by Date: Re: NestWhile
  • Previous by thread: Re: NestWhile
  • Next by thread: Re: NestWhile