solution for problem 5 inputted.