Solution for project euler