A188568 Enumeration table T(n,k) by descending antidiagonals. The order of the list - if n is odd: T(n,1), T(2,n-1), T(n-2,3), ..., T(n-1,2), T(1,n); if n is even: T(1,n), T(n-1,2), T(3,n-2), ..., T(2,n-1), T(n,1).
1, 2, 3, 6, 5, 4, 7, 9, 8, 10, 15, 12, 13, 14, 11, 16, 20, 18, 19, 17, 21, 28, 23, 26, 25, 24, 27, 22, 29, 35, 31, 33, 32, 34, 30, 36, 45, 38, 43, 40, 41, 42, 39, 44, 37, 46, 54, 48, 52, 50, 51, 49, 53, 47, 55
Offset: 1
Examples
The start of the sequence as table: 1, 2, 6, 7, 15, 16, 28, ... 3, 5, 9, 12, 20, 23, 35, ... 4, 8, 13, 18, 26, 31, 43, ... 10, 14, 19, 25, 33, 40, 52, ... 11, 17, 24, 32, 41, 50, 62, ... 21, 27, 34, 42, 51, 61, 73, ... 22, 30, 39, 49, 60, 72, 85, ... ... The start of the sequence as triangular array read by rows: 1; 2, 3; 6, 5, 4; 7, 9, 8, 10; 15, 12, 13, 14, 11; 16, 20, 18, 19, 17, 21; 28, 23, 26, 25, 24, 27, 22; ... Row number k contains permutation of the k numbers: { (k^2-k+2)/2, (k^2-k+2)/2 + 1, ..., (k^2+k-2)/2 + 1 }.
Links
- Boris Putievskiy, Rows n = 1..140 of triangle, flattened
- Boris Putievskiy, Transformations 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
a[n_] := Module[{t, i, j}, t = Floor[(Sqrt[8n-7]-1)/2]; i = n-t(t+1)/2; j = (t^2+3t+4)/2-n; ((i+j-1)(i+j-2) + ((-1)^Max[i,j]+1)i - ((-1)^Max[i,j]-1)j)/2]; Array[a, 55] (* Jean-François Alcover, Jan 26 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 m=((i+j-1)*(i+j-2)+((-1)**max(i,j)+1)*i-((-1)**max(i,j)-1)*j)/2
Formula
a(n) = ((i+j-1)*(i+j-2)+((-1)^max(i,j)+1)*i-((-1)^max(i,j)-1)*j)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor[(-1+sqrt(8*n-7))/2].
Comments