Пример #1
0
def nthPrime(n):
    primes = infiniteSieveOfEratosthenes()
    m = 1
    for i in primes:
        if m == n:
            return i
        m += 1
def largestPrimeFactor(max):
    primes = infiniteSieveOfEratosthenes()
    p = next(primes)

    while(max >= p):
        if max % p == 0:
            lpf = p
            max = max / p
        else:
            p = next(primes)
    return lpf
Пример #3
0
def solve():
    primes = infiniteSieveOfEratosthenes()

    s = 0
    p = next(primes)

    while (p <= 2*10**6):
        s += p
        p = next(primes)

    return s