src/cool_primes/sieves.py
def croft():
    """
    Yields prime integers using Croft Spiral sieve.

    Variant of wheen factorisation modulo 30
    """
    for p in (2, 3, 5):
        yield p
    roots = {9: 3, 25: 5}
    primeroots = frozenset((1, 7, 11, 13, 17, 19, 23, 29))
    selectors = (1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)
    for q in compress(itertools.islice(itertools.count(7), 0, None, 2), itertools.cycle(selectors)):
        if q in roots:
            p = roots[q]
            del roots[q]
            x = q + 2 * p
            while x in roots or (x % 30) not in primeroots:
                x += 2 * p
            roots[x] = p
        else:
            roots[q * q] = q
            yield q

    Yields prime integers using Croft Spiral sieve.

    Variant of wheen factorisation modulo 30
    
Yields prime integers using Croft Spiral sieve.
Variant of wheen factorisation modulo 30
Yields prime integers using Croft Spiral sieve . Variant of wheen factorisation modulo 30
def croft():
    for p in (2, 3, 5):
        yield p
    roots = {9: 3, 25: 5}
    primeroots = frozenset((1, 7, 11, 13, 17, 19, 23, 29))
    selectors = (1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0)
    for q in compress(itertools.islice(itertools.count(7), 0, None, 2), itertools.cycle(selectors)):
        if q in roots:
            p = roots[q]
            del roots[q]
            x = q + 2 * p
            while x in roots or (x % 30) not in primeroots:
                x += 2 * p
            roots[x] = p
        else:
            roots[q * q] = q
            yield q
def croft ( ) : for p in ( 2 , 3 , 5 ) : yield p roots = { 9 : 3 , 25 : 5 } primeroots = frozenset ( ( 1 , 7 , 11 , 13 , 17 , 19 , 23 , 29 ) ) selectors = ( 1 , 0 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 0 ) for q in compress ( itertools . islice ( itertools . count ( 7 ) , 0 , None , 2 ) , itertools . cycle ( selectors ) ) : if q in roots : p = roots [ q ] del roots [ q ] x = q + 2 * p while x in roots or ( x % 30 ) not in primeroots : x += 2 * p roots [ x ] = p else : roots [ q * q ] = q yield q
Yields prime integers using Croft Spiral sieve.
Yields prime integers using Croft Spiral sieve .
"""
    Yields prime integers using Croft Spiral sieve.

    Variant of wheen factorisation modulo 30
    """