Problem 9 & 10

Also optimized sieve