Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #31 Oct 04 2018 19:52:06
%S 1,1,2,1,2,3,1,2,3,4,1,2,3,6,6,1,2,3,4,9,8,1,2,3,4,10,10,11,1,2,3,4,5,
%T 16,11,13,1,2,3,4,5,15,17,12,16,1,2,3,4,5,6,25,18,28,18,1,2,3,4,5,6,
%U 21,26,19,29,26,1,2,3,4,5,6,7,36,27,22,30,28,1,2,3,4,5,6,7,28,37,28,64,53,36
%N Square array of generalized Ulam numbers U(n,k), n>=1, k>=2, read by antidiagonals: U(n,k) = n if n<=k; for n>k, U(n,k) = least number > U(n-1,k) which is a unique sum of k distinct terms U(i,k) with i<n.
%C 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.
%C U(k+1,k) = k*(k+1)/2.
%C U(k+2+j,k) = k^2+j for k>=3 and 0<=j<k.
%C U(2*k+2,k) = k*(3*k-1)/2 for k>=3.
%H Alois P. Heinz, <a href="/A183534/b183534.txt">Antidiagonals n = 1..87</a>
%H <a href="/index/U#Ulam_num">Index entries for Ulam numbers</a>
%e Square array U(n,k) begins:
%e 1, 1, 1, 1, 1, 1, ...
%e 2, 2, 2, 2, 2, 2, ...
%e 3, 3, 3, 3, 3, 3, ...
%e 4, 6, 4, 4, 4, 4, ...
%e 6, 9, 10, 5, 5, 5, ...
%e 8, 10, 16, 15, 6, 6, ...
%p b:= proc(n,i,k,h) option remember;
%p local t;
%p if n<0 or h<0 then 0
%p elif n=0 then `if`(h=0, 1, 0)
%p elif i=0 or h=0 then 0
%p elif h=1 then t:= v(n, k);
%p `if`(t>0 and t<=i, 1, 0)
%p else t:= b(n -U(i, k), i-1, k, h-1);
%p t+ `if`(t>1, 0, b(n, i-1, k, h))
%p fi
%p end:
%p v:= proc() 0 end:
%p U:= proc(n,k) option remember;
%p local m;
%p if n<=k then v(n,k):= n
%p else for m from U(n-1, k)+1
%p while b(m, n-1, k, k)<>1 do od;
%p v(m,k):= n; m
%p fi
%p end:
%p seq(seq(U(n, 2+d-n), n=1..d), d=1..12);
%t 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 *)
%o (PARI)
%o Ulam(N,k=2,v=0)={ my( a=vector(k,i,i), c );
%o for( n=k,N-1, for( t=1+a[n],9e9, c=0;
%o forvec(v=vector(k,i,[i,n]),sum(j=1,k,a[v[j]])==t & c++>1 & next(2),2);
%o c|next; v&print1(t","); a=concat(a,t); break;
%o )); a}
%o /* _M. F. Hasler_ */
%Y Columns k=2-10 give: A002858, A007086, A183527, A183528, A183529, A183530, A183531, A183532, A183533.
%Y Cf. A135737.
%K nonn,tabl,look
%O 1,3
%A _Jonathan Vos Post_ and _Alois P. Heinz_, Jan 05 2011