OFFSET
1,3
COMMENTS
The columns are Ulam-type sequences - see A002858 for further information. Some of these sequences - but not all - seem to have quite simple generating functions.
U(k+1,k) = k*(k+1)/2.
U(k+2+j,k) = k^2+j for k>=3 and 0<=j<k.
U(2*k+2,k) = k*(3*k-1)/2 for k>=3.
LINKS
Alois P. Heinz, Antidiagonals n = 1..87
EXAMPLE
Square array U(n,k) begins:
1, 1, 1, 1, 1, 1, ...
2, 2, 2, 2, 2, 2, ...
3, 3, 3, 3, 3, 3, ...
4, 6, 4, 4, 4, 4, ...
6, 9, 10, 5, 5, 5, ...
8, 10, 16, 15, 6, 6, ...
MAPLE
b:= proc(n, i, k, h) option remember;
local t;
if n<0 or h<0 then 0
elif n=0 then `if`(h=0, 1, 0)
elif i=0 or h=0 then 0
elif h=1 then t:= v(n, k);
`if`(t>0 and t<=i, 1, 0)
else t:= b(n -U(i, k), i-1, k, h-1);
t+ `if`(t>1, 0, b(n, i-1, k, h))
fi
end:
v:= proc() 0 end:
U:= proc(n, k) option remember;
local m;
if n<=k then v(n, k):= n
else for m from U(n-1, k)+1
while b(m, n-1, k, k)<>1 do od;
v(m, k):= n; m
fi
end:
seq(seq(U(n, 2+d-n), n=1..d), d=1..12);
MATHEMATICA
b[n_, i_, k_, h_] := b[n, i, k, h] = Module[{t}, Which[n < 0 || h < 0, 0, n == 0, If[h == 0, 1, 0], i == 0 || h == 0, 0, h == 1, t = v[n, k]; If[t > 0 && t <= i, 1, 0], True, t = b[n-U[i, k], i-1, k, h-1]; t+If[t > 1, 0, b[n, i-1, k, h]] ] ]; v[_, _] = 0; U[n_, k_] := U[n, k] = Module[{m}, If[n <= k, v[n, k] = n, For[m = U[n-1, k]+1, b[m, n-1, k, k] != 1, m++]; v[m, k] = n; m] ]; Table[Table[U[n, 2+d-n], {n, 1, d}], {d, 1, 12}] // Flatten (* Jean-François Alcover, Dec 23 2013, translated from Maple *)
PROG
(PARI)
Ulam(N, k=2, v=0)={ my( a=vector(k, i, i), c );
for( n=k, N-1, for( t=1+a[n], 9e9, c=0;
forvec(v=vector(k, i, [i, n]), sum(j=1, k, a[v[j]])==t & c++>1 & next(2), 2);
c|next; v&print1(t", "); a=concat(a, t); break;
)); a}
/* M. F. Hasler */
CROSSREFS
AUTHOR
Jonathan Vos Post and Alois P. Heinz, Jan 05 2011
STATUS
approved