Solution for Project Euler