updated solution to problem 3 to make that `primes` function more efficient when calculating large primes