Exemplo n.º 1
0
def screen_by_t(a_base, B, t, equal_list):
    clearfile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt")

    ### Посчет времени работы
    start_time = time.time()
    ###

    screening_list = []
    for item in equal_list:  # item - простые числа с одинаковой сигнатурой
        if len(item.primes) >= t - 1 and item.primes[0] > a_base[-1]:
            # берем больше, так как позже будем проверять по группам p1*p2*...*p(t-1)^2<B
            combine = combinations(item.primes, t - 1)  # в порядке возрастания
            for prms in combine:
                prod = np.prod(prms) * prms[-1]
                if prod < B:
                    screening_list.append(Signature(item.sign, prms))

    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ### Запись в файл
    for j in range(len(screening_list)):
        s = f"{j}    {screening_list[j].sign}     {screening_list[j].primes}\n"
        writefile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt", s)
    writefile(f"lib/{B}/{t}/t_signs_{t}_{B}.txt", total_time)

    return screening_list
Exemplo n.º 2
0
def t_2(a_base, B, primes_list):
    clearfile(f"res/jae/2/{a_base}/spsp_{B}.txt")
    spsp = []
    ### Посчет времени работы
    start_time = time.time()
    ###
    i = 1
    for p in primes_list:
        if p < int(root(B, 2)):
            if p > a_base[-1]:
                lmd_p = Lambda_p(a_base, p)
                lmd = numth.lcm(lmd_p, 2)
                for k in range(int(1 + (p - 1) / lmd),
                               int((B - p) / (p * lmd)) + 1, 1):
                    q = 1 + k * lmd
                    if p * q <= B:  # and p * q > B // 100:
                        if numth.is_prime(q) and q > p:
                            if q + 1 == 2 * p:
                                if check_signs(a_base, [p, q]) and psp_2(
                                        a_base, [p, q]):
                                    item = Signature(Sign(a_base, p), [p, q])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/2/{a_base}/spsp_{B}.txt", s)
                                    i += 1
                                    spsp.append(item)
                                else:
                                    continue

                            else:
                                P = p * (1 + k * lmd)
                                if psp(a_base, P) and check_signs(
                                        a_base, [p, q]):
                                    item = Signature(Sign(a_base, p), [p, q])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/2/{a_base}/spsp_{B}.txt", s)
                                    i += 1
                                    spsp.append(item)
                    # else:
                    # break
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###
    writefile(f"res/jae/2/{a_base}/spsp_{B}.txt", total_time)
    return spsp
Exemplo n.º 3
0
def t_more_3(a_base, B, t, primes_list):
    clearfile(f"res/jae/{t}/{a_base}/spsp_{B}.txt")
    spsp = []
    ### Посчет времени работы
    start_time = time.time()
    ###
    i = 1
    equal_list = parsefile(f"lib/equal/{a_base}/equal_signs.txt")

    for item in equal_list:  # item - простые числа с одинаковой сигнатурой
        if len(item.primes) >= t - 1 and item.primes[0] > a_base[-1]:
            # берем больше, так как позже будем проверять по группам p1*p2*...*p(t-1)^2<B
            combine = combinations(item.primes, t - 1)  # в порядке возрастания
            for prms in combine:
                prod = np.prod(prms)
                if prod * prms[-1] < B:
                    a = a_base[0]
                    mu = Lambda_list([a], prms)
                    if gcd(mu, prod) > 1:
                        continue
                    else:
                        import gmpy2
                        c = gmpy2.powmod(prod, -1, mu)
                        for pt in primes_list:
                            if pt > prms[
                                    -1] and pt <= B / prod and pt % mu == c:
                                if psp(a_base, pt * prod) and check_signs(
                                        a_base, [pt, prms[-1]]):
                                    item = Signature(Sign(a_base, pt),
                                                     prms + [pt])
                                    s = f"{i}    {np.prod(item.primes)}    {item.primes}    {item.sign}\n"
                                    writefile(
                                        f"res/jae/{t}/{a_base}/spsp_{B}.txt",
                                        s)
                                    i += 1
                                    spsp.append(item)

                else:
                    break  # к другому item'у т.к. combine упорядочен вертикально и горизонтально

    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###
    writefile(f"res/jae/{t}/{a_base}/spsp_{B}.txt", total_time)
    return spsp
Exemplo n.º 4
0
def find_equal_signs(a_base, primes_list):
    clearfile(f"lib/equal/{a_base}/equal_signs.txt")
    clearfile(f"lib/equal/{a_base}/total_time.txt")

    ### Посчет времени работы
    start_time = time.time()
    ###
    signs_list = [
    ]  # так как нельзя вернуть словарь с ключом-списком, заводим список сигнатур
    primes_dict = {}  # ключами являются индексы в списке сигнатур
    for prime in primes_list[len(a_base):]:
        print("finding equal ... %s" % (prime))
        sign = Sign(a_base, prime)
        if sign in signs_list:
            primes_dict[signs_list.index(sign)].append(prime)
        else:
            signs_list.append(sign)
            primes_dict[signs_list.index(sign)] = [prime]
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ### Преобразование по классу
    equal_list = []
    for j in range(len(signs_list)):
        temp = Signature(signs_list[j], primes_dict[j])
        equal_list.append(temp)

    ###Запись в файл
    tot_s = total_time
    writefile(f"lib/equal/{a_base}/total_time.txt", tot_s)

    s = ""
    for j in range(len(signs_list)):
        s += f"{j}    {equal_list[j].sign}     {equal_list[j].primes}\n"
    writefile(f"lib/equal/{a_base}/equal_signs.txt", s)

    return equal_list
Exemplo n.º 5
0
def step_t_4(a_base, B):
    clearfile(f"res/jnd/4/{a_base}/spsp_{B}.txt")
    clearfile(f"res/jnd/4/{a_base}/n_list_{B}.txt")
    n_list = []

    ### Посчет времени работы
    start_time = time.time()
    ###

    equal_3_list = parsefile(f"res/jnd/3/{a_base}/n_list_{B}.txt")
    # упорядочены по возрастанию p1, где p1<p2
    if len(equal_3_list) != 0:
        for i in range(len(equal_3_list)):
            p1 = equal_3_list[i].primes[0]
            p2 = equal_3_list[i].primes[1]
            p3 = equal_3_list[i].primes[2]
            b = int(p1 * p2 * p3)
            if p1 <= int(root(B, 4)) and b * p3 < B:
                s = ""
                if p1 % 4 == 3:  # Вместо сигнатур вычисляется символ Лежандра
                    p4_3k4 = readfile("primes/4k+3.txt")
                    for p4 in p4_3k4:
                        if p4 * b <= B:  # and p4 * b > B // 100:
                            if p4 > p3:
                                f"p4 {p4}"
                                signss = check_signs(a_base, [p1, p4])
                                if signss:
                                    item = Signature(Sign(a_base, p1),
                                                     [p1, p2, p3, p4])
                                    s += f"{item.primes}    {signss}    {item.sign}\n"
                                    n_list.append(item)

                else:
                    p_exist = np.array([p1, p2, p3])
                    p4_list = next_p(p_exist, a_base, B)
                    if isinstance(p4_list, list):
                        for p4 in p4_list:
                            if p4 * b <= B:  # and p4 * b > B // 100:
                                if p4 > p3:
                                    f"p4 {p4}"
                                    signss = check_signs(a_base, [p1, p4])
                                    if signss:
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2, p3, p4])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                writefile(f"res/jnd/4/{a_base}/n_list_{B}.txt", s)
            else:
                continue
    i = 1
    spsp = []
    ss = ""
    for item in n_list:
        prod = np.prod(item.primes)
        if psp(a_base, prod):
            ss += f"{i}    {prod}    {item.primes}    {item.sign}\n"
            i += 1
            spsp.append(item)
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ss += f"{total_time}\n"
    writefile(f"res/jnd/4/{a_base}/spsp_{B}.txt", ss)
    return np.array(spsp)
Exemplo n.º 6
0
def step_t_3(a_base, B):
    clearfile(f"res/jnd/3/{a_base}/spsp_{B}.txt")
    clearfile(f"res/jnd/3/{a_base}/n_list_{B}.txt")
    n_list = []

    ### Посчет времени работы
    start_time = time.time()
    ###

    # equal_2_list = parsefile(f"res/jnd/2/{a_base}/n_list_{B}.txt")
    # упорядочены по возрастанию p1, где p1<p2
    # if len(equal_2_list) != 0:
    # for i in range(len(equal_2_list)):
    # p1 = equal_2_list[i].primes[0]
    # p2 = equal_2_list[i].primes[1]
    # b = int(p1 * p2)
    for p1 in primes:
        p1 = int(p1)
        print(p1)
        if p1 <= int(root(B, 3)):  # and b * p2 < B:
            if p1 > a_base[-1]:
                print(p1)
                s = ""
                if len(a_base) > 6:
                    a_base = a_base[:6]
                leg1 = []

                for a in a_base:
                    leg1.append(numth.jacobi(a, p1))

                p2_3k4 = readfile("primes/4k+3.txt")
                p2_1k4 = readfile("primes/4k+1.txt")
                p2_5k8 = readfile("primes/8k+5.txt")
                p2_1k8 = readfile("primes/8k+1.txt")

                if p1 % 4 == 3:
                    print(f"p1 34 {p1}")
                    for p2 in p2_3k4:
                        if p2 > p1 and p2 < B and p2 < B:  # на всякий случай проверим
                            print(f"p2 34 {p2}")
                            leg2 = []
                            b = int(p1 * p2)
                            for a in a_base:
                                leg2.append(numth.jacobi(a, p2))
                            if leg1 == leg2:  # Prop.2 inverse is true
                                if b < 2 * 10**6:  # a trick
                                    gcd_23 = int(
                                        gcd(2**(b - 1) - 1, 3**(b - 1) - 1))
                                    factor_list = numth.factorization(gcd_23)
                                    for i in range(len(factor_list)):
                                        p3 = factor_list[i][0]
                                        if p3 * b <= B:  # and p3 * b > B // 100:
                                            if p3 > p2:
                                                print(f"p3 {p3}")
                                                signss = check_signs(
                                                    a_base, [p1, p3])
                                                if signss:
                                                    item = Signature(
                                                        Sign(a_base, p1),
                                                        [p1, p2, p3])
                                                    s += f"{item.primes}    {signss}    {item.sign}\n"
                                                    n_list.append(item)
                                else:
                                    p_exist = np.array([p1, p2])
                                    p3_list = next_p(p_exist, a_base,
                                                     B)  # ищем подходящие p3
                                    if isinstance(p3_list,
                                                  list) and len(p3_list) != 0:
                                        for p3 in p3_list:
                                            if p3 * b <= B:  # and p3 * b > B // 100:
                                                if p3 > p2:
                                                    print(f"p3 {p3}")
                                                    signss = check_signs(
                                                        a_base, [p1, p3])
                                                    if signss:
                                                        item = Signature(
                                                            Sign(a_base, p1),
                                                            [p1, p2, p3])
                                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                                        n_list.append(item)
                                    # else:
                                    # continue  # новый item из equal_2_list
                            # else:
                            # continue

                    for p2 in p2_1k4:
                        print(f"p2 14 to mu {p2}")
                        if Mu_p(a_base, p2) == 4:
                            pass  # переход к mu=4

                elif p1 % 8 == 5:
                    print(f"p1 58 {p1}")

                    for p2 in p2_5k8:
                        if p2 > p1 and p2 < B:
                            print(f"p2 58 {p2}")
                            if len(a_base) > 5:
                                a_base = a_base[:5]

                            leg2 = []
                            b = int(p1 * p2)
                            for a in a_base:
                                leg2.append(numth.jacobi(a, p2))
                            if leg1 == leg2:
                                p_exist = np.array([p1, p2])
                                p3_list = next_p(p_exist, a_base, B)
                                print(p3_list, type(p3_list))
                                if isinstance(p3_list,
                                              list) and len(p3_list) != 0:
                                    for p3 in p3_list:
                                        if p3 * b <= B:  # and p3 * b > B // 100:
                                            if p3 > p2:
                                                print(f"p3 {p3}")
                                                signss = check_signs(
                                                    a_base, [p1, p3])
                                                if signss:
                                                    item = Signature(
                                                        Sign(a_base, p1),
                                                        [p1, p2, p3])
                                                    s += f"{item.primes}    {signss}    {item.sign}\n"
                                                    n_list.append(item)
                                # else:
                                # continue
                            # else:
                            # continue

                    for p2 in p2_1k8:
                        if p2 > p1 and p2 < B:
                            print(f"p2 18 {p2}")
                            if p2 % 16 == 9:
                                print(f"p2 916 {p2}")
                                leg2 = []
                                b = int(p1 * p2)
                                for a in a_base:
                                    leg2.append(numth.jacobi(a, p2))
                                if np.prod(
                                        leg2
                                ) == 1 and p2 > p1:  # если все 1, то произведение 1
                                    p_exist = np.array([p1, p2])
                                    p3_list = next_p(p_exist, a_base, B)
                                    if isinstance(p3_list,
                                                  list) and len(p3_list) != 0:
                                        for p3 in p3_list:
                                            if p3 * b <= B:  # and p3 * b > B // 100:
                                                if p3 > p2:
                                                    print(f"p3 {p3}")
                                                    signss = check_signs(
                                                        a_base, [p1, p3])
                                                    if signss:
                                                        item = Signature(
                                                            Sign(a_base, p1),
                                                            [p1, p2, p3])
                                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                                        n_list.append(item)
                                    else:
                                        continue
                                else:
                                    continue

                        elif p2 % 16 == 1:
                            print(f"p2 116 to mu {p2}")
                            if Mu_p(a_base, p2) == 4:
                                pass  # переход к mu=4

                    for p2 in p2_3k4:
                        if p2 > p1 and p2 < B:  # в тексте этого нет, но на всякий случай проверим
                            print(f"p2 34 {p2}")
                            b = int(p1 * p2)
                            p_exist = np.array([p1, p2])
                            p3_list = next_p(p_exist, a_base, B)
                            # print(f"p3 list {p3_list}")
                            if isinstance(p3_list, list) and len(p3_list) != 0:
                                for p3 in p3_list:
                                    if p3 * b <= B:  # and p3 * b > B // 100:
                                        if p3 > p2:
                                            print(f"p3 {p3}")
                                            signss = check_signs(
                                                a_base, [p1, p3])
                                            if signss:
                                                item = Signature(
                                                    Sign(a_base, p1),
                                                    [p1, p2, p3])
                                                s += f"{item.primes}    {signss}    {item.sign}\n"
                                                n_list.append(item)
                            # else:
                            # continue

                elif p1 % 8 == 1:
                    print(f"p1 18 {p1} p2 any {p2}")
                    e, f = Val(2, p1 - 1), Val(2, Lambda_p(a_base, p1))

                    if len(a_base) > 5:
                        a_base = a_base[:5]
                    for p2 in primes:
                        if p2 > p1 and p2 < B and e == f:
                            if p2 % (2**(e + 1)) == (1 + 2**e) % (2**(
                                    e + 1)):  # !!!! СКОБКИ???
                                leg2 = []
                                b = int(p1 * p2)
                                for a in a_base:
                                    leg2.append(numth.jacobi(a, p2))
                                if leg1 == leg2:
                                    p_exist = np.array([p1, p2])
                                    p3_list = next_p(p_exist, a_base, B)
                                    if isinstance(p3_list,
                                                  list) and len(p3_list) != 0:
                                        for p3 in p3_list:
                                            if p3 * b <= B:  # and p3 * b > B // 100:
                                                if p3 > p2:
                                                    print(f"p3 {p3}")
                                                    signss = check_signs(
                                                        a_base, [p1, p3])
                                                    if signss:
                                                        item = Signature(
                                                            Sign(a_base, p1),
                                                            [p1, p2, p3])
                                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                                        n_list.append(item)
                                    else:
                                        continue
                                else:
                                    continue

                            elif p2 % (2**(e + 2)) == 1:
                                if Mu_p(a_base, p2) == 4:
                                    pass  # переход к mu=4

                            elif p2 % (2**(e + 2)) != 1 and p2 % (2**(
                                    e + 2)) == (1 + 2**(e + 1)) % 2**(
                                        e + 2):  # !!!! СКОБКИ???
                                leg2 = []
                                b = int(p1 * p2)
                                for a in a_base:
                                    leg2.append(numth.jacobi(a, p2))
                                if np.prod(leg2) == 1:
                                    p_exist = np.array([p1, p2])
                                    p3_list = next_p(p_exist, a_base, B)
                                    if isinstance(p3_list,
                                                  list) and len(p3_list) != 0:
                                        for p3 in p3_list:
                                            if p3 * b <= B:  # and p3 * b > B // 100:
                                                if p3 > p2:
                                                    print(f"p3 {p3}")
                                                    signss = check_signs(
                                                        a_base, [p1, p3])
                                                    if signss:
                                                        item = Signature(
                                                            Sign(a_base, p1),
                                                            [p1, p2, p3])
                                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                                        n_list.append(item)
                                    else:
                                        continue
                                else:
                                    continue

                        elif p2 > p1 and p2 < B and f < e:
                            if p2 % 2**f == p1:
                                if f == e - 1 and Mu_p(
                                        a_base,
                                        p1) == 2:  # это есть условие выше
                                    p_exist = np.array([p1, p2])
                                    p3_list = next_p(p_exist, a_base, B)
                                    b = int(p1 * p2)
                                    if isinstance(p3_list,
                                                  list) and len(p3_list) != 0:
                                        for p3 in p3_list:
                                            if p3 * b <= B:  # and p3 * b > B // 100:
                                                if p3 > p2:
                                                    print(f"p3 {p3}")
                                                    signss = check_signs(
                                                        a_base, [p1, p3])
                                                    if signss:
                                                        item = Signature(
                                                            Sign(a_base, p1),
                                                            [p1, p2, p3])
                                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                                        n_list.append(item)
                                    else:
                                        continue
                                else:
                                    continue
                            else:
                                continue

                # p1 is any in primes
                mu_4 = readfile(f"lib/mu/{a_base}/mu_4.txt")
                for p2 in mu_4:
                    if p2 > p1 and p2 < B:  # если p2 mu=4, то не обязательно чтобы и p1 mu=4
                        print(f"p2 mu4 {p2}")
                        p_exist = np.array([p1, p2])
                        p3_list = next_p(p_exist, a_base, B)
                        b = int(p1 * p2)
                        if isinstance(p3_list, list) and len(p3_list) != 0:
                            for p3 in p3_list:
                                if p3 * b <= B:  # and p3 * b > B // 100:
                                    if p3 > p2:
                                        print(f"p3 {p3}")
                                        signss = check_signs(a_base, [p1, p3])
                                        if signss:
                                            item = Signature(
                                                Sign(a_base, p1), [p1, p2, p3])
                                            s += f"{item.primes}    {signss}    {item.sign}\n"
                                            n_list.append(item)
                        # else:
                        # continue
                writefile(f"res/jnd/3/{a_base}/n_list_{B}.txt", s)
            else:
                continue

        else:
            break

    i = 1
    spsp = []
    ss = ""
    for item in n_list:
        prod = np.prod(item.primes)
        if psp(a_base, prod):
            ss += f"{i}    {prod}    {item.primes}    {item.sign}\n"
            i += 1
            spsp.append(item)
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ss += f"{total_time}\n"
    writefile(f"res/jnd/3/{a_base}/spsp_{B}.txt", ss)
    return np.array(spsp)
Exemplo n.º 7
0
def step_t_2(a_base, B, primes_list):
    clearfile(f"res/jnd/2/{a_base}/spsp_{B}.txt")
    clearfile(f"res/jnd/2/{a_base}/n_list_{B}.txt")
    n_list = []
    ### Посчет времени работы
    start_time = time.time()
    ###
    for p1 in primes_list:
        p1 = int(p1)

        if p1 < int(root(B, 2)):
            if p1 > a_base[-1]:

                s = ""
                if p1 < 10**6:
                    gcd_23 = int(gcd(2**(p1 - 1) - 1, 3**(p1 - 1) - 1))
                    factors = sorted(numth.factorization(gcd_23))
                    for i in range(len(factors)):
                        p2 = factors[i][0]
                        if p2 * p1 <= B:  # and p1 * p2 > B // 100:
                            if p2 > p1:  # В дальнейшем для того, чтобы числа в интервалах не повторялись
                                signss = check_signs(a_base, [p1, p2])
                                if signss:
                                    item = Signature(Sign(a_base, p1),
                                                     [p1, p2])
                                    s += f"{item.primes}    {signss}    {item.sign}\n"
                                    n_list.append(item)
                        # else:
                        # break
                elif p1 > 10**8:
                    lmd_p = Lambda_p(a_base, p1)  # lmd_p = p1-1
                    p2 = 1

                    while p2 <= p1:  # and p1 * p2 > B // 100:  # к условию, что p2>p1
                        p2 += lmd_p

                    while p2 * p1 <= B:  # and p1 * p2 > B // 100:
                        signss = check_signs(a_base, [p1, p2])
                        if signss:
                            item = Signature(Sign(a_base, p1), [p1, p2])
                            s += f"{item.primes}    {signss}    {item.sign}\n"
                            n_list.append(Signature(item.sign, [p1, p2]))
                        p2 += lmd_p
                else:  # между 10**6..10**8
                    if len(a_base) > 6:
                        a_base = a_base[:6]
                    lmd_p = Lambda_p(a_base, p1)
                    leg1 = []
                    for a in a_base:
                        leg1.append(numth.jacobi(a, p1))

                    if p1 % 4 == 1:
                        p2_4k3 = readfile("primes/4k+3.txt")
                        p2_4k1 = readfile("primes/4k+1.txt")

                        for p2 in p2_4k3:
                            if p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                if p2 % lmd_p == 1 and p2 > p1:
                                    leg2 = []
                                    for a in a_base:
                                        leg2.append(numth.jacobi(a, p2))
                                    signss = check_signs(a_base, [p1, p2])
                                    if leg1 == leg2 and signss:
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                            # else:
                            # break
                        for p2 in p2_4k1:
                            if p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                if p2 % lmd_p == 1 and p2 > p1:
                                    leg2 = []
                                    for a in a_base:
                                        leg2.append(numth.jacobi(a, p2))
                                    signss = check_signs(a_base, [p1, p2])
                                    if np.prod(
                                            leg2
                                    ) == 1 and signss:  # если все 1, то произведение 1
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                            # else:
                            # break
                    elif p1 % 8 == 5:
                        p2_8k5 = readfile("primes/8k+5.txt")
                        p2_8k1 = readfile("primes/8k+1.txt")

                        for p2 in p2_8k5:
                            if p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                if p2 % lmd_p == 5 and p2 > p1:
                                    leg2 = []
                                    for a in a_base:
                                        leg2.append(numth.jacobi(a, p2))
                                    signss = check_signs(a_base, [p1, p2])
                                    if leg1 == leg2 and signss:
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                            # else:
                            # break
                        for p2 in p2_8k1:
                            if p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                if p2 % lmd_p == 1 and p2 > p1:
                                    leg2 = []
                                    for a in a_base:
                                        leg2.append(numth.jacobi(a, p2))
                                    signss = check_signs(a_base, [p1, p2])
                                    if np.prod(leg2) == 1 and signss:
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                            # else:
                            # break
                    elif p1 % 8 == 1:
                        sign = Sign([2], p1)[0]
                        e, f = Val(2, p1 - 1), Val(2, sign)

                        for p2 in primes:
                            if p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                if p2 > p1 and e == f:
                                    if p2 % (2**(e - 1)) == 2**e % (2**(
                                            e - 1)) and p2 % lmd_p == 1:
                                        leg2 = []
                                        for a in a_base:
                                            leg2.append(numth.jacobi(a, p2))
                                        signss = check_signs(a_base, [p1, p2])
                                        if leg1 == leg2 and signss:
                                            item = Signature(
                                                Sign(a_base, p1), [p1, p2])
                                            s += f"{item.primes}    {signss}    {item.sign}\n"
                                            n_list.append(item)
                                    elif p2 % 2**(e +
                                                  1) == 1 and p2 % lmd_p == 1:
                                        leg2 = []
                                        for a in a_base:
                                            leg2.append(numth.jacobi(a, p2))
                                        signss = check_signs(a_base, [p1, p2])
                                        if np.prod(leg2) == 1 and signss:
                                            item = Signature(
                                                Sign(a_base, p1), [p1, p2])
                                            s += f"{item.primes}    {signss}    {item.sign}\n"
                                            n_list.append(item)
                                elif p2 > p1 and f < e and p1 * p2 <= B:  # and p1 * p2 > B // 100:
                                    signss = check_signs(a_base, [p1, p2])
                                    if p2 % lmd_p == 1 and signss:
                                        item = Signature(
                                            Sign(a_base, p1), [p1, p2])
                                        s += f"{item.primes}    {signss}    {item.sign}\n"
                                        n_list.append(item)
                            # else:
                            # break
                writefile(f"res/jnd/2/{a_base}/n_list_{B}.txt", s)
        else:
            continue

    i = 1
    spsp = []
    ss = ""
    for item in n_list:
        prod = np.prod(item.primes)
        if psp(a_base, prod):
            ss += f"{i}    {prod}    {item.primes}    {item.sign}\n"
            i += 1
            spsp.append(item)
    ###
    total_time = "--- %s seconds ---\n" % (time.time() - start_time)
    ###

    ss += f"{total_time}\n"
    writefile(f"res/jnd/2/{a_base}/spsp_{B}.txt", ss)
    return np.array(spsp)