Solution to the 3n + 1 problem written in Ruby