for _ in range(11): r,=s={-1} exec'n=r=min({r+1,r+2,r+3}-s)\nwhile{n}-s:s|={n};n=(n/2,3*n+1)[n%2]\n'*input() print r
1 2 3 4 5 6 7 8 9 10 50
0 1 3 6 7 9 12 15 18 19 114
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!