MathGroup Archive 2002

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

Search the Archive

Re: NestWhile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32559] Re: [mg32519] NestWhile
  • From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
  • Date: Sat, 26 Jan 2002 04:08:46 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com


In[8]:=
NestWhileList[f,7,#â? 1&]

Out[8]=
{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1}

On Friday, January 25, 2002, at 04:57  PM, 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
>
>
>
>
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/



  • Prev by Date: Re: NestWhile
  • Next by Date: Re: NestWhile
  • Previous by thread: Re: NestWhile
  • Next by thread: Re: NestWhile