HW3 Problem 12

Different from YJH's results, don't know what's wrong with my code.