%I #42 Dec 03 2018 18:28:00
%S 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,
%T 26,28,30,32,34,36,38,40,42,44,29,31,33,35,37,39,41,43,45,47,49,51,53,
%U 55,57,59,61,63,65,46,48,50,52,54,56,58,60,62,64,66,68
%N Array read by downward antidiagonals: T(n,k) = (n+k-1)*(n+k-2) + n + floor((n+k)/2)*(1-2*floor((n+k)/2)), for n, k > 0
%C 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).
%C 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.
%C Permutation of the natural numbers.
%C 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.
%H Boris Putievskiy, <a href="/A210521/b210521.txt">Rows n = 1..140 of triangle, flattened</a>
%H Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations [of] Integer Sequences And Pairing Functions</a> arXiv:1212.2732 [math.CO], 2012.
%H Eric W. Weisstein, <a href="http://mathworld.wolfram.com/PairingFunction.html">MathWorld: Pairing functions</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F As a table: T(n,k) = (n+k-1)*(n+k-2) + 2*n + floor((n+k)/2)*(1-2*floor((n+k)/2)).
%F As a linear sequence: a(n) = 2*A000027(n) + A204164(n)*(1-2*A204164(n)).
%F a(n) = 2*n+v*(1-2*v), where t = floor((-1+sqrt(8*n-7))/2) and v = floor((t+2)/2).
%F 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
%e The start of the sequence as a table:
%e 1, 3, 2, 8, 7, 17, 16, 30, 29, ...
%e 5, 4, 10, 9, 19, 18, 32, 31, 49, ...
%e 6, 12, 11, 21, 20, 34, 33, 51, 50, ...
%e 14, 13, 23, 22, 36, 35, 53, 52, 74, ...
%e 15, 25, 24, 38, 37, 55, 54, 76, 75, ...
%e 27, 26, 40, 39, 57, 56, 78, 77, 103, ...
%e 28, 42, 41, 59, 58, 80, 79, 105, 104, ...
%e 44, 43, 61, 60, 82, 81, 107, 106, 136, ...
%e 45, 63, 62, 84, 83, 109, 108, 138, 137, ...
%e ...
%e The start of the sequence as a triangular array read by rows:
%e 1;
%e 3, 5;
%e 2, 4, 6;
%e 8, 10, 12, 14;
%e 7, 9, 11, 13, 15;
%e 17, 19, 21, 23, 25, 27;
%e 16, 18, 20, 22, 24, 26, 28;
%e 30, 32, 34, 36, 38, 40, 42, 44;
%e 29, 31, 33, 35, 37, 39, 41, 43, 45;
%e ...
%e 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:
%e 1,3,5;
%e 2,4,6,8,10,12,14;
%e 7,9,11,13,15,17,19,21,23,25,27;
%e 16,18,20,22,24,26,28,30,32,34,36,38,40,42,44;
%e 29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65;
%e ...
%e 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).
%e Considered as a triangle, the rows have constant parity.
%t T[n_, k_] := (n+k-1)(n+k-2) + 2n + Floor[(n+k)/2](1 - 2 Floor[(n+k)/2]);
%t Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Dec 03 2018 *)
%o (Python)
%o t=int((math.sqrt(8*n-7)-1)/2)
%o v=int((t+2)/2)
%o result=2*n+v*(1-2*v)
%Y Cf. A000027, A204164, the main diagonal is A084849.
%K nonn,tabl
%O 1,2
%A _Boris Putievskiy_, Jan 26 2013