Shortcut Collatz function (source code)

= Shortcut Collatz function

The <Collatz function> is not very elegant in that the odd $3n + 1$ case is always even because $n$ is odd, so it is always predictably followed by a division by two. This is not the case for the even case, where the result can be either even or odd.

A much more elegant formulation is to immediately also divide by two when the number is odd:
$$
\frac{3n + 1}{2}
$$