Problem 2 complete in function format.