More improvements to Euler problem #4