|
MAPLE
|
F:= proc(d) # get all terms with d digits
local res, m, prefs, i, t, qmax, qmin, smax, smin, cand, s;
res:= NULL;
m:= max(1, floor(d/2-1));
prefs:= [2, 4, 6]*10^(d-1);
for i from 1 to m-1 do
prefs:= map(t -> (t + 2*10^(d-1-i), t+4*10^(d-1-i), t+6*10^(d-1-i)), prefs)
od;
for t in prefs do
qmax:= t + 6*(10^(d-m)-1)/9; smax:= floor(sqrt(8*qmax+1));
qmin:= t + 2*(10^(d-m)-1)/9; smin:= ceil(sqrt(8*qmin+1));
smin:= smin + 1 - (smin mod 2);
for s from smin to smax by 2 do
cand:= (s^2 -1)/8;
if cand mod 10 = 6 and convert(convert(cand, base, 10), set) subset {2, 4, 6} then
res:= res, cand;
fi
od
od;
res;
end proc:
|