{ a = vectorsmall(10 000); u = 1; f = [0]; \\ leading terms m = [0]; \\ multiples of leading terms for (d = 1, oo, for (k = 1, d, n = d+1-k; if (k==1, if (#f < n, f = concat(f, vector(#f)); m = concat(m, vector(#m)); ); m[n] = f[n] = u; ); while (m[n]<=#a && a[m[n]], m[n] += f[n]; ); if (m[n]<=#a, a[m[n]] = d*(d-1)/2+k; while (a[u], print (u " " a[u]); if (u++ > #a, break (3); ); ); ); ); ); } quit