solution to problem 58
solution to problem 6