Solved Problem 10 using Sieve of Eratosthenes