Solved problem 7.
Used Sieve of Eratosthenes