[seqfan] Re: Computing sequences up to first non-distinct element: re-inventing the wheel?

Alonso Del Arte alonso.delarte at gmail.com
Wed Feb 15 18:29:45 CET 2012


Thank you very much, Hans. It took me a couple of minutes, but I
figured out how I can apply this concept to other problems.

Al

On 2/15/12, Hans Havermann <gladhobo at teksavvy.com> wrote:
> Alonso Del Arte:
>
>> My question is: is there a built-in Mathematica command that in this
>> example would stop at the second occurrence of 4?
>
> In[1]:= Collatz[n_Integer]:=Switch[Mod[n,2],0,n/2,1,3n+1]
> In[2]:= NestWhileList[Collatz,7, Unequal, All]
> Out[2]= {7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4}
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>


-- 
Alonso del Arte
Author at SmashWords.com<https://www.smashwords.com/profile/view/AlonsoDelarte>
Musician at ReverbNation.com <http://www.reverbnation.com/alonsodelarte>



More information about the SeqFan mailing list