generate primes using sieve of eratosthenes for better performance
added answers for reference (in case algo changes in util break correctness)