nextp:= proc(P) local k, m, newP, PL, PG, iv, i;
m:= nops(P);
for k from m-1 by -1 do
if P[k] > P[k+1] then
PL, PG:= selectremove(`<`, P[k+1..m], P[k]);
iv:= max[index](PL);
return [op(P[1..k-1]), PL[iv], op(sort([op(subsop(iv=P[k], PL)), op(PG)], `>`))]
fi
od
end proc:
V:= Array(0..21): V[0]:= 1:
P:= [seq(i$2, i=9..0, -1)]: count:= 1:
while count < 3 do
x:= add(P[i]*10^(19-i), i=1..19):
w:= numtheory:-bigomega(x);
if w <= 2 and V[w] = 0 then V[w]:= x; count:= count+1; fi;
P:= nextp(P);
od:
P:= [seq(i$2, i=9..0, -1)]:
while count < 22 do
x:= add(P[i]*10^(20-i), i=1..20):
w:= numtheory:-bigomega(x);
if w <= 21 and V[w] = 0 then V[w]:= x; count:= count+1; fi;
P:= nextp(P);
od:
convert(V, list);
|