Ejemplo n.º 1
0
def solve():
    INIT = 100000
    INC = 100000
    primes = mathlib.getPrimes(INIT)
    while True:
        if len(primes) >= 10001:
            return primes[10000]
        else:
            INIT = INIT + INC
            primes = mathlib.getPrimes(INIT)
Ejemplo n.º 2
0
def solve():
    primes = mathlib.getPrimes(1000)
    primes.reverse()
    for p in primes:
        c = 1
        while (10**c - 1) % p != 0:
            c += 1
        if (p-c) == 1:
            return p
    return -1
Ejemplo n.º 3
0
def solve():
    primes = mathlib.getPrimes(100)
    target = 10
    while True:
        ways = [0] * (target + 1)
        ways[0] = 1
        for num in primes:
            for i in range(num, target + 1):
                ways[i] += ways[i - num]
        result = ways[target]
        if result > 5000:
            break
        target += 1
    return target
Ejemplo n.º 4
0
def solve():
    primes = mathlib.getPrimes(1000000)
    primesum = [0]
    s = 0
    count = 0
    while s < 1000000:
        s += primes[count]
        primesum.append(s)
        count += 1
    terms = 1
    for i in range(count):
        for j in range(i + terms, count):
            n = primesum[j] - primesum[i]
            if (j-i>terms and mathlib.isPrime(n)):
                terms, maxprime = j-i, n
    return maxprime
Ejemplo n.º 5
0
def solve():
    MAXNUM = 1000000 + 1
    eulerlist = [0] * MAXNUM
    # Sieve of Eratosthenes getting to get list of primes under 10^6
    primes = mathlib.getPrimes(MAXNUM)
    # compute the ¦Õ(n) of the primes
    # ¦Õ(n) = n-1 if n is a prime
    for p in primes:
        eulerlist[p] = p - 1
    
    # compute the ¦Õ(n) of other number
    for i in range(2, MAXNUM):
        if eulerlist[i] != 0:
            pass
        else:
            for p in primes:
                # ¦Õ(pq) = ¦Õ(p)*¦Õ(q) if p is a relatively prime to q,
                # if p is a prime, it is a relatively prime to any number.
                if i % p == 0:
                    if int(i/p) % p == 0:
                        eulerlist[i] = eulerlist[int(i/p)] * p
                    else:
                        eulerlist[i] = eulerlist[int(i/p)] * (p - 1)
                    break
                else:
                    pass
                
    # find the max ratio
    reault = 6
    maxRatio = 1.66666
    # computer all ratio
    for i in range(11, MAXNUM):
        if float(i) / eulerlist[i] > maxRatio:
            result = i
            maxRatio = float(i) / eulerlist[i]
        else:
            pass
    return result, maxRatio
Ejemplo n.º 6
0
def solve():
    return sum(mathlib.getPrimes(2000000))
Ejemplo n.º 7
0
def solve():
    D = 1000
    return max([(pellEquation(d), d) for d in mathlib.getPrimes(D)])[1]