OFFSET

1,2

COMMENTS

Enumeration table T(n,k). The order of the list: T(1,1)=1; for k>0: T(1,2*k+1),T(1,2*k); T(2,2*k),T(2,2*k-1); ... T(2*k,2),T(2*k,1); T(2*k+1,1).

The order of the list is descent stairs from the northeast to southwest: step to the west, step to the south, step to the west and so on. The length of each step is 1 or alternation of elements pair adjacent antidiagonals.

Permutation of the natural numbers.

a(n) is a pairing function: a function that reversibly maps Z^{+} x Z^{+} onto Z^{+}, where Z^{+} is the set of integer positive numbers.

LINKS

Boris Putievskiy, Rows n = 1..140 of triangle, flattened

Boris Putievskiy, Transformations [of] Integer Sequences And Pairing Functions arXiv:1212.2732 [math.CO], 2012.

Eric W. Weisstein, MathWorld: Pairing functions

FORMULA

As a table: T(n,k) = (n+k-1)*(n+k-2) + 2*n + floor((n+k)/2)*(1-2*floor((n+k)/2)).

a(n) = 2*n+v*(1-2*v), where t = floor((-1+sqrt(8*n-7))/2) and v = floor((t+2)/2).

G.f. as a table: (2 - 2*y - 5*y^2 + 6*y^3 + 3*y^4 + x*y*(1 + 3*y-5*y^2 + y^3) + x^2*(- 3 + 7*y + 5*y^2 - 11*y^3 - 6*y^4) - x^3*(- 4 + 5*y + 7*y^2 - 9*y^3 + y^4) + x^4*(1 - y - 4*y^2 + y^3 + 7*y^4))/((- 1 + x)^3*(1 + x)^2*(- 1 + y)^3*(1 + y)^2). - Stefano Spezia, Dec 03 2018

EXAMPLE

The start of the sequence as a table:

1, 3, 2, 8, 7, 17, 16, 30, 29, ...

5, 4, 10, 9, 19, 18, 32, 31, 49, ...

6, 12, 11, 21, 20, 34, 33, 51, 50, ...

14, 13, 23, 22, 36, 35, 53, 52, 74, ...

15, 25, 24, 38, 37, 55, 54, 76, 75, ...

27, 26, 40, 39, 57, 56, 78, 77, 103, ...

28, 42, 41, 59, 58, 80, 79, 105, 104, ...

44, 43, 61, 60, 82, 81, 107, 106, 136, ...

45, 63, 62, 84, 83, 109, 108, 138, 137, ...

...

The start of the sequence as a triangular array read by rows:

1;

3, 5;

2, 4, 6;

8, 10, 12, 14;

7, 9, 11, 13, 15;

17, 19, 21, 23, 25, 27;

16, 18, 20, 22, 24, 26, 28;

30, 32, 34, 36, 38, 40, 42, 44;

29, 31, 33, 35, 37, 39, 41, 43, 45;

...

The sequence as array read by rows, the length of row r is 4*r-1. First 2*r-1 numbers are from row 2*r-1 of the triangular array above. Last 2*r numbers are from row 2*r of the triangular array. The start of the sequence:

1,3,5;

2,4,6,8,10,12,14;

7,9,11,13,15,17,19,21,23,25,27;

16,18,20,22,24,26,28,30,32,34,36,38,40,42,44;

29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65;

...

Row r contains 4*r-1 numbers: 2*r^2-5*r+4, 2*r^2-5*r+6, 2*r^2-5*r+8, ..., r*(2*r+3).

Considered as a triangle, the rows have constant parity.

MATHEMATICA

T[n_, k_] := (n+k-1)(n+k-2) + 2n + Floor[(n+k)/2](1 - 2 Floor[(n+k)/2]);

Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Dec 03 2018 *)

PROG

(Python)

t=int((math.sqrt(8*n-7)-1)/2)

v=int((t+2)/2)

result=2*n+v*(1-2*v)

CROSSREFS

KEYWORD

nonn,tabl

AUTHOR

Boris Putievskiy, Jan 26 2013

STATUS

approved