Problem 3 subsection 4-B

Checking to see if the solution works for all cases.