Question 7 Solved using Sieve of Eratosthenes