Use generator to compute sum of n primes