solution for problem 10 with prime sieve