base = 10 \\ numbers obtained by replacing a number (without leading zeros) \\ appearing in the expansion of n by one of its divisors. rr = [0] row(n) = { my (d = digits(n, base), nb = 1); rr[1] = n; for (i = 1, #d, if (d[i], for (j = i, #d, my (x = fromdigits(d[i..j], base)); fordiv (x, t, my (y = fromdigits(concat([ d[1..i-1], digits(t, base), d[j+1..#d] ]), base)); if (nb++ > #rr, rr = concat(rr, vector(#rr)); ); rr[nb] = y; ); ); ); ); return (Set(rr[1..nb])) } { for (n = 1, 1000, r = row(n); apply (v -> print (m++ " " v), r); ); } quit