示例#1
0
def primesTo( start=2, stop=10 ):
    """Generate a sequence of primes to a limit.

    >>> list(primesTo(stop=10))
    [2, 3, 5, 7]
    """
    for p in primeGen():
        if p < start: continue
        if p >= stop: break
        yield p
示例#2
0
def max_phi_gen():
    """
    >>> list( max_phi_gen() )
    [(2, [2]), (6, [2, 3]), (30, [2, 3, 5]), (210, [2, 3, 5, 7]), (2310, [2, 3, 5, 7, 11]), (30030, [2, 3, 5, 7, 11, 13]), (510510, [2, 3, 5, 7, 11, 13, 17])]
    """
    limit= 1000000
    primes= []
    prod= 1
    prods= []
    for p in primeGen():
        if prod*p > limit: break
        prod *= p
        primes.append( p )
        prods.append( prod )
        yield prod, primes[:]
示例#3
0
def makePrimes(start=1000, stop=10000):
    """Make primes in the given range.

    >>> from euler49 import makePrimes
    >>> p4 = list(makePrimes())
    >>> len(p4)
    1061
    >>> p4 # doctest: +ELLIPSIS
    [1009, ..., 9973]
    """
    pg= primeGen()
    for p in pg:
        if p >= stop:
            break
        if start <= p:
            yield p
示例#4
0
 def __init__( self, count=1 ):
     self.pg= primeGen()
     for c in range(count):
         self.primeSeq = [next(self.pg)]
         self.primeSet= set(self.primeSeq)
示例#5
0
 def primes(limit):
     for p in euler07.primeGen():
         if p >= limit: break
         yield p