Redoing Problem 10 using a sieve