NestWhile

• To: mathgroup at smc.vnet.net
• Subject: [mg23039] NestWhile
• From: "Alan W.Hopper" <awhopper at hermes.net.au>
• Date: Thu, 13 Apr 2000 02:43:25 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Others like myself who are still using Mathematica 3,  may have been
interested to see that the new cryptic @@@ function can be programmed
into a user function for version 3, as explained by Hartmut Wolf and
Daniel Reeves.

But I have a query to pose about another new version 4 function  ,
that is NestWhile, which I assume can also be approximated in version
3.0.

This code was taken from Eric Weisstein's IntegerSequences.m package,
obtained from the mathworld.wolfram site ;

KeithNumberQ[n_Integer?Positive]:=(KeithSequence[n][[-1]] == n)

KeithSequence[n_Integer?Positive]:= Module[{d = IntegerDigits[n], l},
l = Length[d];
NestWhile[Append[#, Plus @@ Take[#,-l]] &, d, #[[-1]] < n &]
]

The first Keith Number is 197 and it's Keith Sequence should be
{1, 9, 7, 17, 33, 57, 107, 197},  or similar.

as starting with the digits of 197 ,
1 + 9 + 7 = 17
9 + 7 + 17 = 33
7 + 17 + 33 = 57
17 + 33 + 57 = 107
33 + 57 + 107 = 197

Other small Keith Numbers are  742, 1104, 1537, 2208,
a large one is 97295849958669 .
(see Don Piele - Mathematica Pearls - Mathematica in Research and
Education - Vol 6 No 3 , p 50,  also  Vol 7 No 1, p 45.

So the question is how can a Mathematica 3 version of NestWhile be
substituted into the above code?

Alan Hopper

awhopper at hermes.net.au

```

• Prev by Date: Re: Hydrogen atom modelling for P-Chem
• Next by Date: Re: 3 credit online university course - Intro to Mathematica
• Previous by thread: Re: Hydrogen atom modelling for P-Chem
• Next by thread: Re: NestWhile