Problem 15 and some Math utilities