Exemplo n.º 1
0
def _get_factorized(base, pow):
    x = _integers.get((base, pow), None)
    if x is None:
        x = Integer(base**pow - 1)
        x.factorize()
        _integers[(base, pow)] = x
    return x
Exemplo n.º 2
0
def _get_factorized(base, pow):
    x = _integers.get((base, pow), None)
    if x is None:
        x = Integer(base ** pow - 1)
        x.factorize()
        _integers[(base, pow)] = x
    return x
Exemplo n.º 3
0
def _min_power(p, n, primes):
    """Minimal power t such that \pi(p(p^t-1)(p^2t-1)...(p^nt-1)) contains given set
    of primes.
    """
    t = 0
    primes = set(primes)
    primes.remove(p)
    while primes:
        t += 1
        x = Integer()
        for i in range(1, n + 1):
            x *= _get_factorized(p, t * i)
            #x = prod(Integer(p ** (t * i) - 1) for i in range(1, n + 1))
        x.factorize()
        primes -= set(x.factors)
    return t
Exemplo n.º 4
0
def _min_power(p, n, primes):
    """Minimal power t such that \pi(p(p^t-1)(p^2t-1)...(p^nt-1)) contains given set
    of primes.
    """
    t = 0
    primes = set(primes)
    primes.remove(p)
    while primes:
        t += 1
        x = Integer()
        for i in range(1, n + 1):
            x *= _get_factorized(p, t * i)
            # x = prod(Integer(p ** (t * i) - 1) for i in range(1, n + 1))
        x.factorize()
        primes -= set(x.factors)
    return t