def main():
    import sympy
    import p37_Truncatable_primes as p37
    lucky_prime = 0
    plist = []
    for i in range(2, 10):
        plist = pandigital_list(i)
        for j in plist[:]:
            if p37.is_prime(j) and lucky_prime < j:
                lucky_prime = j
    print(lucky_prime)
Пример #2
0
def main():
    i = 1
    x = 1
    np = 0
    N = 1
    while True:
        i = i + 1
        for j in range(0,3):
            x = x + 2 * i - 2
            if p37.is_prime(x):
                np = np + 1
        x = x + 2 * i - 2
        N = N + 4
        if np / N < 0.1:
            print(i * 2 - 1)
            return
def main():
    import sympy

    plist = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]

    i = 33
    while True:
        i = i + 2
        if p37.is_prime(i):
            plist.append(i)
        else:
            local_list = [(i - j) // 2 for j in plist]
            for k in local_list:
                if is_square(k):
                    print(i, "woo...")
                    break
            else:
                print(i, "is the final number.")
                break
def main(n):
    import sympy as sp
    for i in sp.primerange(100000, 1000000):
        digi_last = i % 10
        s = str(i//10)
        # if len(set(s)) > 3:
        #     continue
        for c in range(0, 2):
            if s.count(str(c)) == 3:
                count = 0
                local_list = []
                for d in range(c, 10):
                    new_s = s.replace(str(c), str(d))
                    new_digi = int(new_s) * 10 + digi_last
                    if p37.is_prime(new_digi):
                        count = count + 1
                        local_list.append(new_digi)
                        if count == n:
                            print("the lucky one:", i)
                            print(local_list)
                            return
                print(local_list)
            if s.count(str(c)) == 4:
                count = 0       # Replace the last one
                local_list = []
                for d in range(c, 10):
                    new_s = s.replace(str(c), str(d), 3)
                    new_digi = int(new_s) * 10 + digi_last
                    if p37.is_prime(new_digi):
                        count = count + 1
                        local_list.append(new_digi)
                        if count == n:
                            print("the lucky one:", i)
                            print(local_list)
                            return
                print(local_list)
                count = 0       # Replace the second one
                local_list = []
                for d in range(c, 10):
                    new_s = s.replace(str(c), str(d), 1)
                    new_s = new_s.replace(str(c), 'a', 1)
                    new_s = new_s.replace(str(c), str(d), 2)
                    new_s = new_s.replace('a', str(c), 1)
                    new_digi = int(new_s) * 10 + digi_last
                    if p37.is_prime(new_digi):
                        count = count + 1
                        local_list.append(new_digi)
                        if count == n:
                            print("the lucky one:", i)
                            print(local_list)
                            return
                print(local_list)
                count = 0       # Replace the third one
                local_list = []
                for d in range(c, 10):
                    new_s = s.replace(str(c), str(d), 2)
                    new_s = new_s.replace(str(c), 'a', 1)
                    new_s = new_s.replace(str(c), str(d), 1)
                    new_s = new_s.replace('a', str(c), 1)
                    new_digi = int(new_s) * 10 + digi_last
                    if p37.is_prime(new_digi):
                        count = count + 1
                        local_list.append(new_digi)
                        if count == n:
                            print("the lucky one:", i)
                            print(local_list)
                            return
                print(local_list)
                count = 0       # Replace the third one
                local_list = []
                for d in range(c, 10):
                    new_s = s.replace(str(c), 'a', 1)
                    new_s = new_s.replace(str(c), str(d), 3)
                    new_s = new_s.replace('a', str(c), 1)
                    new_digi = int(new_s) * 10 + digi_last
                    if p37.is_prime(new_digi):
                        count = count + 1
                        local_list.append(new_digi)
                        if count == n:
                            print("the lucky one:", i)
                            print(local_list)
                            return
                print(local_list)
        else:
            continue