Exemplo n.º 1
0
def main():
    for i in PrimeGenerator(under=9999):
        if i < 1488:
            continue
        else:
            counter = 0
            candidate = collector(find_permute(i))
            for j in candidate:
                if j != i and is_prime(j) and is_prime(2 * j-i) and (2 * j - i) in candidate:
                    return i, j, 2 * j - i
Exemplo n.º 2
0
def main():
    for i in PrimeGenerator(under=9999):
        if i < 1488:
            continue
        else:
            counter = 0
            candidate = collector(find_permute(i))
            for j in candidate:
                if j != i and is_prime(j) and is_prime(2 * j - i) and (
                        2 * j - i) in candidate:
                    return i, j, 2 * j - i
Exemplo n.º 3
0
def main():
    result = 0
    limit = 1000000
    chain_length = 0
    mapping = {}
    current_chain = []
    for x in range(2, limit + 1):
        if is_prime(x):
            continue
        current_chain = []
        failed = False
        _x = x
        while _x not in current_chain:
            current_chain.append(_x)
            _x = get_proper_divisors(_x)
            if _x > limit or mapping.setdefault(_x, False):
                failed = True
                break

        if not failed:
            if len(current_chain) > chain_length:
                chain_length = len(current_chain)
                result = min(current_chain)

        for j in current_chain:
            mapping[j] = False

    return result
Exemplo n.º 4
0
def main():
    max_found = -1
    for n in xrange(3, 10):
        for j in generator(n):
            if is_prime(j) and j > max_found:
                max_found = j
    print "Finally..", max_found
Exemplo n.º 5
0
def verify(number):
    result = False
    for i in range(1, int(sqrt(number / 2)) + 1):
        if is_prime(number - i * i * 2):
            result = True
            break
    return result
Exemplo n.º 6
0
def main():
    max_found = -1
    for n in range(3, 10):
        for j in generator(n):
            if is_prime(j) and j > max_found:
                max_found = j
    print("Finally..", max_found)
Exemplo n.º 7
0
def verify(number):
    result = False
    for i in xrange(1, int(sqrt(number / 2))+1):
        if is_prime(number - i * i * 2):
            result = True
            break
    return result
Exemplo n.º 8
0
def gen_odd_composite():
    n = 1
    while True:
        c = 2 * n + 1
        if not is_prime(c):
            yield c

        n += 1
Exemplo n.º 9
0
def gen_odd_composite():
    n = 1
    while True:
        c = 2 * n + 1
        if not is_prime(c):
            yield c

        n += 1
Exemplo n.º 10
0
def main():
    result = 0
    for i in range(1, 1000000):
        possible = True
        for j in num_rotate(i):
            if not is_prime(j):
                possible = False
                break
        result += possible
    print(result)
Exemplo n.º 11
0
def main():
    n, maxlen = 1000000, 0
    Set = list(PrimeGenerator(under=10000))
    newb = 2
    for a in range(4):
        for b in range(newb, len(Set)):
            subset = Set[a:b]
            s = sum(subset)
            if is_prime(s) and s < n and len(subset) > maxlen:
                length = len(subset)
                sumprime = s
                maxlen = length
                newb = b
    print(sumprime)
Exemplo n.º 12
0
def main():
    n, maxlen = 1000000, 0
    Set = list(PrimeGenerator(under=10000))
    newb = 2
    for a in range(4):
        for b in range(newb, len(Set)):
            subset = Set[a:b]
            s = sum(subset)
            if is_prime(s) and s < n and len(subset) > maxlen:
                length = len(subset)
                sumprime = s
                maxlen = length
                newb = b
    print(sumprime)
Exemplo n.º 13
0
def test_length(a, b):
    n = 0
    while is_prime(quadratic(n, a, b)):
        n += 1
    return n
Exemplo n.º 14
0
def check_number(number):
    possible = True
    for i in truncate_gen(number):
        if not is_prime(i):
            possible = False
    return possible
Exemplo n.º 15
0
def test_length(a, b):
    n = 0
    while is_prime(quadratic(n,a,b)):
        n += 1
    return n
Exemplo n.º 16
0
def check_pair(a, b):
    if is_prime(a * (10**len(str(b))) + b) and is_prime(b *
                                                        (10**len(str(a))) + a):
        return True
    else:
        return False
Exemplo n.º 17
0
def check_pair(a, b):
    if is_prime(a * (10**len(str(b))) + b) and is_prime(b * (10**len(str(a))) + a):
        return True
    else:
        return False