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 #32 Jan 08 2024 14:30:13
%S 1,3,4,2,6,5,8,9,11,12,7,15,10,14,13,17,18,20,21,23,24,16,28,19,27,22,
%T 26,25,30,31,33,34,36,37,39,40,29,45,32,44,35,43,38,42,41,47,48,50,51,
%U 53,54,56,57,59,60,46,66,49,65,52,64,55,63,58,62,61,68
%N T(n,k) = (2*(n+k)^2 - 2*(n+k) - 4*k + 6 + (2*k-2)*(-1)^n + (2*k-1)*(-1)^k + (-2*n+1)*(-1)^(n+k))/4; 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). Let m be natural number. The order of the list:
%C T(1,1)=1;
%C T(3,1), T(2,2), T(1,3);
%C T(2,1), T(1,2);
%C ...
%C T(1,2*m+1), T(1,2*m), T(2, 2*m-1), T(3, 2*m-1),... T(2*m,1), T(2*m+1,1);
%C T(2*m,2), T(2*m-2,4), ...T(2,2*m);
%C ...
%C Movement along two adjacent antidiagonals. The first row consists of phases: step to the west, step to the southwest, step to the south. The second row consists of phases: 2 steps to the north, 2 steps to the east. The length of each step is 1.
%H Boris Putievskiy, <a href="/A213197/b213197.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 Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PairingFunction.html">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) = (2*(n+k)^2 - 2*(n+k) - 4*k + 6 + (2*k-2)*(-1)^n + (2*k-1)*(-1)^k + (-2*n+1)*(-1)^(n+k))/4.
%F As a linear sequence:
%F a(n) = (2*A003057(n)^2 - 2*A003057(n) - 4*A004736(n) + 6 + (2*A004736(n)-2)*(-1)^A002260(n) + (2*A004736(n)-1)*(-1)^A004736(n) + (-2*A002260(n)+1)*(-1)^A003056(n))/4;
%F a(n) = (2*(t+2)^2 - 2*(t+2) - 4*j + 6 + (2*j-2)*(-1)^i + (2*j-1)*(-1)^j + (-2*i+1)*(-1)^t)/4, where i = n - t*(t+1)/2, j = (t*t + 3*t + 4)/2 - n, t = floor((-1+sqrt(8*n-7))/2).
%e The start of the sequence as a table:
%e 1, 3, 2, 8, 7, 17, 16, ...
%e 4, 6, 9, 15, 18, 28, 31, ...
%e 5, 11, 10, 20, 19, 33, 32, ...
%e 12, 14, 21, 27, 34, 44, 51, ...
%e 13, 23, 22, 36, 35, 53, 52, ...
%e 24, 26, 37, 43, 54, 64, 75, ...
%e 25, 39, 38, 56, 55, 77, 76, ...
%e ...
%e The start of the sequence as a triangular array read by rows:
%e 1;
%e 3, 4;
%e 2, 6, 5;
%e 8, 9, 11, 12;
%e 7, 15, 10, 14, 13;
%e 17, 18, 20, 21, 23, 24;
%e 16, 28, 19, 27, 22, 26, 25;
%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 2*r-2 of the triangular array above.
%e Last 2*r-1 numbers are from row 2*r-1 of the triangular array above.
%e 1;
%e 3, 4, 2, 6, 5;
%e 8, 9, 11, 12, 7, 15, 10, 14, 13;
%e 17, 18, 20, 21, 23, 24, 16, 28, 19, 27, 22, 26, 25;
%e ...
%e Row r contains permutation of 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-2*r+2, 2*r*r-2*r+1.
%p T:=(n,k)->(2*(n+k)^2-2*(n+k)-4*k+6+(2*k-2)*(-1)^n+(2*k-1)*(-1)^k+(1-+2*n)*(-1)^(n+k))/4: seq(seq(T(k,n-k),k=1..n-1),n=1..13); # _Muniru A Asiru_, Dec 06 2018
%t T[n_, k_] := (2(n+k)^2 - 2(n+k) - 4k + 6 + (2k-2)(-1)^n + (2k-1)(-1)^k + (-2n+1)(-1)^(n+k))/4;
%t Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* _Jean-François Alcover_, Dec 06 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=(2*(t+2)**2-2*(t+2)-4*j+6 +(2*j-2)*(-1)**i+(2*j-1)*(-1)**j+(-2*i+1)*(-1)**t)/4
%Y Cf. A002260, A004736, A003056, A003057.
%Y Table T(n,k) contains: in rows A130883, A033816, A100037, A000384, A100038, A014106, A091823; in columns A001844, A142463, A090288, A139570, A046092, A051890, A059993, A097080, A181510, A137882, A152813.
%K nonn,tabl
%O 1,2
%A _Boris Putievskiy_, Mar 01 2013