Solution for Problem #10 (using an optimized version of The sieve of Eratosthenes)