|
MAPLE
|
f:= proc(m, n)
local L, nL, d, r, K, Kp, tmin, t, V, Vt, x;
L:= convert(m, base, 10);
nL:= nops(L);
L:= Vector(L);
for d from 1 do
r:= infinity;
V:= Vector(nL+d);
for K in combinat:-choose(nL+d, nL) do
V[K]:= L;
Kp:= sort(convert({$1..nL+d} minus convert(K, set), list));
if Kp[-1] = nL+d then tmin:= 10^(d-1) else tmin:= 0 fi;
for t from tmin to 10^d-1 do
Vt:= convert(10^d+t, base, 10);
V[Kp]:= Vector(Vt[1..-2]);
x:= add(10^(i-1)*V[i], i=1..nL+d);
if x > r then break fi;
if x mod n = 0 then r:= x; break fi;
od;
od;
if r < infinity then return r fi
od;
end proc:
A[1]:= 1:
for n from 2 to 30 do A[n]:= f(A[n-1], n) od:
|