Hailstone problem solution