solution for problem 8
solution for problem 9