Solution for Project Euler.net