def hailstone n
  seq = [n]
  until n == 1
    n = (n.even?)? (n / 2): (3 * n + 1)
    seq << n
  end
  seq
end

puts 
hs27 = hailstone 27
p [hs27.length, hs27[0..3], hs27[-4..-1]]


n = (1 ... 100_000).max_by{|n| hailstone(n).length}
puts 
puts