コード例 #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
コード例 #2
0
ファイル: max_divisors.py プロジェクト: aikoven/calculations
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
コード例 #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
コード例 #4
0
ファイル: max_divisors.py プロジェクト: aikoven/calculations
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