Solve the Hailstone program from Assignment 2