Project Euler 31 best attempt.