A216249 T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2-2, if k=1 and (n mod 2)=1; T(n,k)=((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2, else. Table T(n,k) read by antidiagonals; n , k > 0.
1, 3, 2, 4, 5, 6, 8, 7, 12, 11, 9, 10, 13, 14, 15, 17, 16, 21, 20, 25, 24, 18, 19, 22, 23, 26, 27, 28, 30, 29, 34, 33, 38, 37, 42, 41, 31, 32, 35, 36, 39, 40, 43, 44, 45, 47, 46, 51, 50, 55, 54, 59, 58, 63, 62, 48, 49, 52, 53, 56, 57, 60, 61, 64, 65, 66, 68, 67, 72, 71, 76, 75, 80, 79, 84, 83, 88, 87
Offset: 1
Examples
The start of the sequence as table: 1 3 4 8 9 17 18... 2 5 7 10 16 19 29... 6 12 13 21 22 34 35... 11 14 20 23 33 36 50... 15 25 26 38 39 55 56... 24 27 37 40 54 57 75... 28 42 43 59 60 80 81... ... The start of the sequence as triangular array read by rows: 1; 3, 2; 4, 5, 6; 8, 7, 12, 11; 9, 10, 13, 14, 15; 17, 16, 21, 20, 25, 24; 18, 19, 22, 23, 26, 27, 28; ... As an array read by rows, where the length of row number r is 4*r-3: First 2*r-2 numbers are from the row number 2*r-2 of triangle array, located above. Last 2*r-1 numbers are from the row number 2*r-1 of triangle array, located above. 1; 3, 2, 4, 5, 6; 8, 7, 12, 11, 9, 10, 13, 14, 15; 17, 16, 21, 20, 25, 24, 18, 19, 22, 23, 26, 27, 28; ... Row number r contains permutation of the 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+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 Weisstein's World of Mathematics, Pairing functions
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Mathematica
T[n_, k_] := ((n+k)^2 - 4k + 3 - 2(-1)^n + (-1)^k - (n+k-4)(-1)^(n+k))/2 - 2Boole[k == 1 && OddQ[n]]; Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Nov 20 2019 *)
-
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-2*(-1)**i-(t-2)*(-1)**t)/2 if j==1 and (i%2)==1: result=result-2
Formula
As a table:
T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2-2, if k=1 and (n mod 2)=1;
T(n,k) = ((n+k)^2-4*k+3-2*(-1)^n+(-1)^k-(n+k-4)*(-1)^(n+k))/2, else.
As a linear sequence:
a(n) = ((t+2)^2-4*j+3-2*(-1)^i+(-1)^j-(t-2)*(-1)^t)/2-2, if j=1 and (i mod 2)=1;
a(n) = ((t+2)^2-4*j+3-2*(-1)^i+(-1)^j-(t-2)*(-1)^t)/2, else; where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2).
Comments