A solution to problem two taken from projecteuler.net/problems