One of my favorite C.S. professors, in a first-year grad class, gave out 3 of these problems as homework, including the first one, without indicating whether it was easy or hard. The problem was posed as a while loop, and the question was, does the loop terminate for arbitrary n>0, so it seemed very tractable: given: n > 0. while n != 1: if n is odd: n = 3n + 1 else: n = n/2 It was a tease. I tried a couple of differ…
This is a pretty good example of how far computing hardware has come. I was able to eliminated 2 to 50k in 81ms in completely unoptimized C# just now. Makes me wonder who has taken this approach the farthest these days.
I just implemented it too. I notice that by 100K, you get an intermediate result of size just less than 2^31, but at 1M, you get an intermediate result of size about 2^36. Maybe I went up above 100K.
For more: http://en.wikipedia.org/wiki/Collatz_conjecture#Experimental..., which includes some very nice plots, and a fractal construction when iterating an extension of the map to the complex plane. Whew! (On the other hand, https://xkcd.com/710/)