OFFSET
1,4
FORMULA
Let p(i,j) be the position of (i,j) in the ordering. Then p(i,j) = ((i+j)^2-i-3j+2)/2. Inversely, the pair (i,j) in a given position p is given by i=p-q(q-1)/2 and j=q+1-i, where q=floor((1+sqrt(8k-7))/2).
EXAMPLE
Flatten the ordered lattice points (1,1) < (1,2) < (2,1) < (1,3) < (2,2) < ... as 1,1, 1,2, 2,1, 1,3, 2,2, ...
MATHEMATICA
lexicographicLattice[{dim_, maxHeight_}]:= Flatten[Array[Sort@Flatten[(Permutations[#1]&)/@IntegerPartitions[#1+dim-1, {dim}], 1]&, maxHeight], 1]; Flatten@lexicographicLattice[{2, 12}] (* Peter J. C. Moses, Feb 10 2011 *)
u[x_] := Floor[3/2 + Sqrt[2*x]]; v[x_] := Floor[1/2 + Sqrt[2*x]]; n[x_] := x - v[x]*(v[x] - 1)/2; k[x_] := 1 - x + u[x]*(u[x] - 1)/2; Flatten[Table[{n[m], k[m]}, {m, 45}]] (* L. Edson Jeffery, Jun 20 2015 *)
PROG
(PARI) a(n)= if(n<1, 0, 1+(-1)^(n%2) * (binomial((n+1)%2+(sqrtint(4*n)+1)\2, 2)-n\2)) /* Michael Somos, Mar 06 2004 */
CROSSREFS
KEYWORD
nonn
AUTHOR
Clark Kimberling, Sep 07 2000
EXTENSIONS
Extended by Clark Kimberling, Feb 10 2011
STATUS
approved