Solved Problem 12 using more efficient getDivisors(x)