Project Euler problem 24