As of May 4 2007 the scripts will autodetect your timezone settings. Nothing here has to be changed, but there are a few things

Please follow this blog

Search this blog

Saturday, July 16, 2011

Collatz sequence - Revisited

This following Mathematica code prints the Collatz sequence for n to 1.
g[n_]:=NestWhileList[Piecewise[{{3#+1,OddQ[#]},{#/2,EvenQ[#]}}]&,n,#>1&]

For example
g[23]={23,70,35,106,53,160,80,40,20,10,5,16,8,4,2,1}


Problem 14 of the Euler Project is about the Collatz sequence. Officially it is a conjecture that every sequence starting with n ends in 1.

I spend so much time on 3x+1.... My first blog post in 2005 was on the Collatz sequence. I am able to generate sequences of any length ( thus including very large lengths ) but they end with 1 by definition. It's sort of a paradox.

No comments:

Post a Comment

Popular Posts

Welcome to The Bridge

Mathematics: is it the fabric of MEST?
This is my voyage
My continuous mission
To uncover hidden structures
To create new theorems and proofs
To boldly go where no man has gone before




(Raumpatrouille – Die phantastischen Abenteuer des Raumschiffes Orion, colloquially aka Raumpatrouille Orion was the first German science fiction television series. Its seven episodes were broadcast by ARD beginning September 17, 1966. The series has since acquired cult status in Germany. Broadcast six years before Star Trek first aired in West Germany (in 1972), it became a huge success.)