Код:
zsearch(p:int, Y:vec)=
{
local(j, i1, i2, it, t):int;
if(p<5, j= 0:int,
i1= 1:int; i2= (#Y):int; t= -1:int;
while(p!=t,
it= ((i2+i1)\2):int; t= Y[it]:int;
if(p<t, i2= (it-1):int,
if(p>t, i1= (it+1):int,
j= it:int; break
)
);
if((i1>i2), j= 0:int; break)
)
);
return(j:int)
};
pkh()=
{
local(Z, w):vec;
local(L, n, n24, g, i, j, k, h, h3, a, m, a1, m1, a2, m2, d1, d2):int;
local(s):bool;
Z= matrix(0, 3):vec;
\\Z= read("pkh6.dbt"):vec;
L= (#Z~):int;
if(L==0, n= (5):int, n= (Z[L,1]+2):int);
while(n < 10^6,
if(n%3, if(n%7, if(n%11, if(n%13, if(n%17, if(n%31, if(n%37, if(n%41, if(n%43, if(n%59, if(n%61, if(n%67, if(n%73, if(n%79, if(n%83, if(n%89,
n24= (n%24):int;
if((n24==1)||(n24==5)||(n24==19)||(n24==23), if(issquarefree(n),
s= 1:bool; g= 1:int;
if(isprime(n),
h= znorder(Mod(2, n)):int; h3= znorder(Mod(3, n)):int;
if(!(h%h3),
k= znlog(3, Mod(2, n), h);
g= (h/h3):int;
if(g-1,
i= zsearch(g, Z[,1]):int;
if(i,
a1= (n*k):int; m1= (n*h):int;
a2= (g*Z[i,2]):int; m2= (g*Z[i,3]):int;
,
s= 0:bool
)
)
,
s= 0:bool
)
,
w= divisors(n):vec;
d1= w[2]:int;
i= zsearch(d1, Z[,1]):int;
if(i,
d2= w[#w-1]:int;
j= zsearch(d2, Z[,1]):int;
if(j,
a1= (d1*Z[i,2]):int; m1= (d1*Z[i,3]):int;
a2= (d2*Z[j,2]):int; m2= (d2*Z[j,3]):int;
g= 2:int;
,
s= 0:bool
)
,
s= 0:bool
)
);
if(s,
if(g-1,
a= lift(trap(, 0, chinese(Mod(a1, m1), Mod(a2, m2)))):int;
if(a, m= lcm(m1, m2); k= (a/n):int; h= (m/n):int, s= 0:bool)
)
);
if(s, if((!(h%24))&&(kronecker(6, k%24)==-1), if(g-1, print(n)), Z= concat(Z, [n,k,h])))
))
))))))))))))))));
n+=2
);
write("pkh.dbt", Z); print(); print(#Z~);
};
Из первого миллиона отфильтровываются 35388 подходящих чисел.