Exemplo n.º 1
0
def prob_35(dim = 1000000):
    s = 0
    for p in erat():
        if p > dim:
            return s
        if check_rot(p):
            print p
            s += 1
Exemplo n.º 2
0
def prob_37():
    res = []
    for n in erat():
        if len(res) == 11:
            return sum(res)
        s = str(n)
        r = [ s[i:] for i in range(1, len(s)) ]
        l = [ s[:i] for i in range(1, len(s)) ]
        truncs = map(int, [s] + r + l)
        if n > 10 and all(map(is_prime, truncs)):
            res.append(n)
Exemplo n.º 3
0
def prob_7(nth = 10001):
    return islice(erat(), nth-1, nth).next()
Exemplo n.º 4
0
#!/usr/bin/env python

from utils import erat
f = open('primes.txt', 'w')
for idx, p in enumerate(erat()):
    if idx == 10000:
        f.close()
        break
    # at worst we lose only 999 primes
    f.write(str(p) + '\n')