problem 16 and 17
pretty straightforward