T(n) = n*(n+1)/2; { w = 13; \\ compute the sequence for n = 0..2^w - 1 a = vector(2^w-1); \\ for n > 0 u = 1; \\ seed seq = [[0,0,0]]; \\ [k, A364885(k), e(k)] print ("0 0"); \\ We compute the terms of A364885 < 2^w \\ with increasing Hamming weight for (h = 1, w, new seq = vector(binomial(w, h)); nb = 0; n = 0; while (nb < #new seq, n++; first = 0; for (k = 1, #seq, while (1, v = bitor(seq[k][2], 2^seq[k][3]); if (v >= 2^w, \\ too big break, a[v], \\ already seen seq[k][3]++, \\ first term in that row? if (!first, first++; \\ adjust n? n = max(n, seq[k][1]); ); if (seq[k][1] > n, \\ k is too far, move to next row break (2), new seq[nb++] = [pos = T(n) + seq[k][1], v, 0]; a[v] = pos; while (a[u], print (u " " a[u]); if (u++ > #a, quit; ); ); \\ search another term on the same row break (1); ); ); ); ); ); seq = new seq; ); }