solution for assignment2/problem3
solve problem 5