A213197 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.
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, 26, 25, 30, 31, 33, 34, 36, 37, 39, 40, 29, 45, 32, 44, 35, 43, 38, 42, 41, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 46, 66, 49, 65, 52, 64, 55, 63, 58, 62, 61, 68
Offset: 1
Examples
The start of the sequence as a table: 1, 3, 2, 8, 7, 17, 16, ... 4, 6, 9, 15, 18, 28, 31, ... 5, 11, 10, 20, 19, 33, 32, ... 12, 14, 21, 27, 34, 44, 51, ... 13, 23, 22, 36, 35, 53, 52, ... 24, 26, 37, 43, 54, 64, 75, ... 25, 39, 38, 56, 55, 77, 76, ... ... The start of the sequence as a triangular array read by rows: 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, 26, 25; ... The start of the sequence as an array read by rows, the length of row r is 4*r-3. First 2*r-2 numbers are from row 2*r-2 of the triangular array above. Last 2*r-1 numbers are from row 2*r-1 of the triangular array above. 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, 26, 25; ... Row r contains permutation of 4*r-3 numbers from 2*r*r-5*r+4 to 2*r*r-r: 2*r*r-5*r+5, 2*r*r-5*r+6, ..., 2*r*r-2*r+2, 2*r*r-2*r+1.
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 Weisstein's World of Mathematics, Pairing functions
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Maple
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
-
Mathematica
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; Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Dec 06 2018 *)
-
Python
t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n 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
Formula
As a table:
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.
As a linear sequence:
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;
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).
Comments