Adding problem 52 solution.