HW1 problem 8 solved