A211377 T(n,k) = ((k + n)^2 - 4*k + 3 + (-1)^k - (k + n - 2)*(-1)^(k + n))/2; n, k > 0, read by antidiagonals.
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, 27, 28, 30, 31, 34, 35, 38, 39, 42, 43, 29, 32, 33, 36, 37, 40, 41, 44, 45, 47, 48, 51, 52, 55, 56, 59, 60, 63, 64, 46, 49, 50, 53, 54, 57, 58, 61, 62, 65, 66, 68
Offset: 1
Examples
The start of the sequence as a table: 1, 3, 2, 8, 7, 17, 16, 30, 29, 47, 46, ... 4, 5, 9, 10, 18, 19, 31, 32, 48, 49, 69, ... 6, 12, 11, 21, 20, 34, 33, 51, 50, 72, 71, ... 13, 14, 22, 23, 35, 36, 52, 53, 73, 74, 98, ... 15, 25, 24, 38, 37, 55, 54, 76, 75, 101, 100, ... 26, 27, 39, 40, 56, 57, 77, 78, 102, 103, 131, ... 28, 42, 41, 59, 58, 80, 79, 105, 104, 134, 133, ... 43, 44, 60, 61, 81, 82, 106, 107, 135, 136, 168, ... 45, 63, 62, 84, 83, 109, 108, 138, 137, 171, 170, ... 64, 65, 85, 86, 110, 111, 139, 140, 172, 173, 209, ... 66, 88, 87, 113, 112, 142, 141, 175, 174, 212, 211, ... ... The start of the sequence as triangle array read by rows: 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, 27, 28; 30, 31, 34, 35, 38, 39, 42, 43; 29, 32, 33, 36, 37, 40, 41, 44, 45; 47, 48, 51, 52, 55, 56, 59, 60, 63, 64; 46, 49, 50, 53, 54, 57, 58, 61, 62, 65, 66; ... 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 number 2*r-2 of the triangular array above. Last 2*r-1 numbers are from row number 2*r-1 of the triangular array above. 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, 27, 28; 30, 31, 34, 35, 38, 39, 42, 43, 29, 32, 33, 36, 37, 40, 41, 44, 45; 47, 48, 51, 52, 55, 56, 59, 60, 63, 64, 46, 49, 50, 53, 54, 57, 58, 61, 62, 65, 66; ... Row number r contains permutation 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-r-4, 2*r*r-r-1, 2*r*r-r.
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
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Mathematica
T[n_, k_] := ((k+n)^2 - 4k + 3 + (-1)^k - (k+n-2)(-1)^(k+n))/2; Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Nov 29 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=((t+2)**2-4*j+3+(-1)**j-t*(-1)**(t+2))/2
Formula
As a table:
T(n,k) = ((k + n)^2 - 4*k + 3 + (-1)^k - (k + n - 2)*(-1)^(k + n))/2.
As a linear sequence:
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).
Comments