Solution for problem 4
Solution for problem 5