def sum_primes(limit): n = 3 primes = [2] while n < limit: if not divisible_by_any(n, primes): primes.append(n) n += 2 return sum(primes)
def nth_prime(N): primes = [2] N -= 1 x = 3 while N > 0: if not divisible_by_any(x, primes): primes.append(x) N -= 1 x += 2 return primes[-1]
def extendPrimes(self, N): x = self.primes[-1] + 2 while self.primes[-1] < N: if not divisible_by_any(x, self.primes): self.primes.append(x)