def maximalPrimeGapIncreasesViaSieve(n): primes = PrimeSieve.primes(n) last = primes[0] maxsofar = 0 result = [] nprimes = len(primes) for i in range(1,nprimes): curr = primes[i] last = primes[i-1] if (curr - last > maxsofar): maxsofar = curr - last result.append((last,maxsofar)) return result
def maximalPrimeGapIncreasesViaSieve(n): primes = PrimeSieve.primes(n) last = primes[0] maxsofar = 0 result = [] nprimes = len(primes) for i in range(1, nprimes): curr = primes[i] last = primes[i - 1] if (curr - last > maxsofar): maxsofar = curr - last result.append((last, maxsofar)) return result
def __init__(self, _max): # Cheat by precomupting primes up to sqrt(max) # How else to get the ath prime? intmax = max(10, int(sqrt(float(_max)))) self.primes = PrimeSieve.primes(intmax) self.maxprime = self.primes[len(self.primes) - 1]
def __init__(self, _max): # Cheat by precomupting primes up to sqrt(max) # How else to get the ath prime? intmax = max(10,int(sqrt(float(_max)))) self.primes = PrimeSieve.primes(intmax) self.maxprime = self.primes[len(self.primes)-1]