Program 2 Solution for project euler