solves problem 10 using sieve of eratosphenes