Optimized problem 10 to use a Primes iterator.