Пример #1
0
def main():
    numthry.sieve(10**ubound)
    pans = set(
        int("".join(p)) for p in itertools.permutations(
            str(d) for d in range(1, ubound + 1)))
    panprimes = numthry.sprimes & pans
    print(max(panprimes))
Пример #2
0
def main():
    numthry.sieve(100^2+bound*100+bound)
    best = (0,0,0)
    for a in range(-bound,bound+1):
        for b in range(-bound,bound+1):
            if numthry.isprime(b):
                n = 0
                while numthry.isprime(n*n + a*n + b):
                    n += 1
                if n > best[2]:
                    best = (a, b, n)
    print(best)
Пример #3
0
def main():
    numthry.sieve(100^2+bound*100+bound)
    best = (0,0,0)
    for a in range(-bound,bound+1):
        for b in range(-bound,bound+1):
            if numthry.isprime(b):
                n = 0
                while numthry.isprime(n*n + a*n + b):
                    n += 1
                if n > best[2]:
                    best = (a, b, n)
    print(best)
Пример #4
0
def main():
    numthry.sieve(ubound)
    p = set(numthry.primes)
    count = 0
    for n in numthry.primes:
        l = [d for d in list(str(n))]
        # check if all rotations of n are prime and, if so, increment count
        if all([(int(''.join(l[i:] + l[:i])) in p) for i in range(len(l))]):
            count += 1
##            print("n:", n, "| rotations:", [int(''.join(l[i:] + l[:i]))
##                    for i in range(len(l))])

    print(count)
Пример #5
0
def main():
    numthry.sieve(ubound)
    p = set(numthry.primes)
    count = 0
    for n in numthry.primes:
        l = [d for d in list(str(n))]
        # check if all rotations of n are prime and, if so, increment count
        if all([(int(''.join(l[i:] + l[:i])) in p) for i in range(len(l))]):
            count += 1


##            print("n:", n, "| rotations:", [int(''.join(l[i:] + l[:i]))
##                    for i in range(len(l))])

    print(count)
Пример #6
0
def main():
    numthry.sieve(1000000)
    count = 0
    total = 0
    n = 10

    while count < 11:
        if numthry.isprime(n):
            s = str(n)
            truncs = [s[i:] for i in range(len(s))] + [s[:i+1] for i in range(len(s)-1)]
            if all(numthry.isprime(int(t)) for t in truncs):
                total += n
                count += 1
        n += 1
    print(total)
Пример #7
0
def main():
    numthry.sieve(1000000)
    count = 0
    total = 0
    n = 10

    while count < 11:
        if numthry.isprime(n):
            s = str(n)
            truncs = [s[i:] for i in range(len(s))
                      ] + [s[:i + 1] for i in range(len(s) - 1)]
            if all(numthry.isprime(int(t)) for t in truncs):
                total += n
                count += 1
        n += 1
    print(total)
Пример #8
0
def main():
    numthry.sieve(10**ubound)
    pans = set(int("".join(p)) for p in itertools.permutations(str(d)
            for d in range(1,ubound + 1)))
    panprimes = numthry.sprimes & pans
    print(max(panprimes))