示例#1
0
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)
示例#2
0
文件: 10.py 项目: k-natt/public
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)
示例#3
0
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]
示例#4
0
文件: 7.py 项目: k-natt/public
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]
示例#5
0
文件: 58.py 项目: k-natt/public
 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)
示例#6
0
文件: 58.py 项目: k-natt/public
	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)