Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #28 Apr 12 2024 12:00:38
%S 1,3,4,2,5,6,8,9,12,13,7,10,11,14,15,17,18,21,22,25,26,16,19,20,23,24,
%T 27,28,30,31,34,35,38,39,42,43,29,32,33,36,37,40,41,44,45,47,48,51,52,
%U 55,56,59,60,63,64,46,49,50,53,54,57,58,61,62,65,66,68
%N T(n,k) = ((k + n)^2 - 4*k + 3 + (-1)^k - (k + n - 2)*(-1)^(k + n))/2; n, k > 0, read by 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.
%C Enumeration table T(n,k). The order of the list:
%C T(1,1)=1;
%C T(1,3), T(1,2), T(2,1), T(2,2), T(3,1);
%C ...
%C T(1,n), T(1,n-1), T(2,n-2), T(2,n-1), T(3,n-2), T(3,n-3)...T(n,1);
%C ...
%C Descent by snake along two adjacent antidiagonal - step to the west, step to the southwest, step to the east, step to the southwest and so on. The length of each step is 1.
%C Table contains:
%C row 1 is alternation of elements A130883 and A033816,
%C row 2 accommodates elements A100037 in odd places;
%C column 1 is alternation of elements A000384 and A091823,
%C column 2 is alternation of elements A071355 and A014106,
%C column 3 accommodates elements A130861 in even places;
%C main diagonal accommodates elements A188135 in odd places,
%C diagonal 1, located above the main diagonal, is alternation of elements A033567 and A033566,
%C diagonal 2, located above the main diagonal, is alternation of elements A139271 and A033585.
%H Boris Putievskiy, <a href="/A211377/b211377.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:
%F T(n,k) = ((k + n)^2 - 4*k + 3 + (-1)^k - (k + n - 2)*(-1)^(k + n))/2.
%F As a linear sequence:
%F a(n) = ((t + 2)^2 - 4*j + 3 + (-1)^j - t*(-1)^t)/2, where j = (t*t + 3*t + 4)/2 - n and t = int((sqrt(8*n - 7) - 1)/ 2).
%e The start of the sequence as a table:
%e 1, 3, 2, 8, 7, 17, 16, 30, 29, 47, 46, ...
%e 4, 5, 9, 10, 18, 19, 31, 32, 48, 49, 69, ...
%e 6, 12, 11, 21, 20, 34, 33, 51, 50, 72, 71, ...
%e 13, 14, 22, 23, 35, 36, 52, 53, 73, 74, 98, ...
%e 15, 25, 24, 38, 37, 55, 54, 76, 75, 101, 100, ...
%e 26, 27, 39, 40, 56, 57, 77, 78, 102, 103, 131, ...
%e 28, 42, 41, 59, 58, 80, 79, 105, 104, 134, 133, ...
%e 43, 44, 60, 61, 81, 82, 106, 107, 135, 136, 168, ...
%e 45, 63, 62, 84, 83, 109, 108, 138, 137, 171, 170, ...
%e 64, 65, 85, 86, 110, 111, 139, 140, 172, 173, 209, ...
%e 66, 88, 87, 113, 112, 142, 141, 175, 174, 212, 211, ...
%e ...
%e The start of the sequence as triangle array read by rows:
%e 1;
%e 3, 4;
%e 2, 5, 6;
%e 8, 9, 12, 13;
%e 7, 10, 11, 14, 15;
%e 17, 18, 21, 22, 25, 26;
%e 16, 19, 20, 23, 24, 27, 28;
%e 30, 31, 34, 35, 38, 39, 42, 43;
%e 29, 32, 33, 36, 37, 40, 41, 44, 45;
%e 47, 48, 51, 52, 55, 56, 59, 60, 63, 64;
%e 46, 49, 50, 53, 54, 57, 58, 61, 62, 65, 66;
%e ...
%e The start of the sequence as an array read by rows, the length of row r is 4*r-3.
%e First 2*r-2 numbers are from row number 2*r-2 of the triangular array above.
%e Last 2*r-1 numbers are from row number 2*r-1 of the triangular array above.
%e 1;
%e 3, 4, 2, 5, 6;
%e 8, 9, 12, 13, 7, 10, 11, 14, 15;
%e 17, 18, 21, 22, 25, 26, 16, 19, 20, 23, 24, 27, 28;
%e 30, 31, 34, 35, 38, 39, 42, 43, 29, 32, 33, 36, 37, 40, 41, 44, 45;
%e 47, 48, 51, 52, 55, 56, 59, 60, 63, 64, 46, 49, 50, 53, 54, 57, 58, 61, 62, 65, 66;
%e ...
%e Row number r contains permutation 4*r-3 numbers from 2*r*r-5*r+4 to 2*r*r-r:
%e 2*r*r-5*r+5, 2*r*r-5*r+6,...2*r*r-r-4, 2*r*r-r-1, 2*r*r-r.
%t T[n_, k_] := ((k+n)^2 - 4k + 3 + (-1)^k - (k+n-2)(-1)^(k+n))/2;
%t Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Nov 29 2018 *)
%o (Python)
%o t=int((math.sqrt(8*n-7) - 1)/ 2)
%o i=n-t*(t+1)/2
%o j=(t*t+3*t+4)/2-n
%o result=((t+2)**2-4*j+3+(-1)**j-t*(-1)**(t+2))/2
%Y Cf. A000384, A014106, A033566, A033567, A033585, A033816, A071355, A091823, A100037, A130861, A130883, A139271, A188135.
%K nonn,tabl
%O 1,2
%A _Boris Putievskiy_, Feb 07 2013