Sunday May 10, 2009
This mathematical problem is gauged to test your ability to code up simple problems in an efficient way.

Description


Given the rules for a sequence:
If n is even: n = n / 2
If n is odd: n = 3n + 1

For example, if the starting number is 5 the sequence is:
5 -> 16 -> 8 -> 4 -> 2 -> 1

Find the largest starting number under ten million that will generate the longest run of this sequence and ends in 1.

The sequence in question is called the Collatz Problem and is thought to always terminate.

Notes:
*Because integers in the sequence can reach numbers greater than 32 bits, non-integer or larger-than-32- bit integers may be required, depending on the implementation.
Show solution
Challenge Resources:
©1994-2014   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube Not Logged In. Login