Project Euler problem 3