MathGroup Archive 2002

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

Search the Archive

RE: NestWhile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32587] RE: [mg32519] NestWhile
  • From: "Higinio Ramos" <higra at usal.es>
  • Date: Wed, 30 Jan 2002 03:19:06 -0500 (EST)
  • References: <200201250757.CAA09822@smc.vnet.net>
  • Reply-to: "Higinio Ramos" <higra at usal.es>
  • Sender: owner-wri-mathgroup at wolfram.com

----- Original Message -----
From: Tom De Vries <tdevries at shop.westworld.ca>
To: mathgroup at smc.vnet.net
Subject: [mg32587] [mg32519] NestWhile


> 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
>
>
The Collatz sequence until it stop in 1 may be generated by
NestWhileList[f, 450, ! (#1 == 1) &]
Higinio



  • References:
    • NestWhile
      • From: Tom De Vries <tdevries@shop.westworld.ca>
  • Prev by Date: Re: operating system
  • Next by Date: Gross Bug in Simplify
  • Previous by thread: NestWhile
  • Next by thread: Re: NestWhile