OFFSET
1,2
COMMENTS
Permutation of the natural numbers.
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.
Enumeration table T(n,k). The order of the list:
T(1,1) = 1;
T(1,3), T(2,2), T(1,2), T(2,1), T(3,1);
. . .
T(1,n), T(2,n-1), T(1,n-1), T(2,n-2), T(3,n-2), T(4,n-3)...T(n,1);
...
Descent by snake along two adjacent antidiagonals - step to the southwest, step to the north, step to the southwest, step to the south and so on. The length of each step is 1. Phase four steps is rotated 90 degrees counterclockwise and the mirror of the phase A211377.
Table contains the following:
row 2 accommodates elements A033816 in even places;
column 4 accommodates elements A130861 in odd places;
diagonal 1, located above the main diagonal, accommodates elements A033585 in even places,
diagonal 2, located above the main diagonal, accommodates elements A139271 in odd places,
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
FORMULA
EXAMPLE
The start of the sequence as a table:
1 4 2 9 7 8 16 ...
5 3 10 8 19 17 32 ...
6 13 11 22 20 35 33 ...
14 12 23 21 36 34 53 ...
15 26 24 39 37 56 54 ...
27 25 40 38 57 55 78 ...
28 43 41 60 58 81 79 ...
...
The start of the sequence as a triangle array read by rows:
1
4 5
2 3 6
9 10 13 14
7 8 11 12 15
18 19 22 23 26 27
16 17 20 21 24 25 28
...
The start of the sequence as array read by rows, the length of row 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
4 5 2 3 6
9 10 13 14 7 8 11 12 15
18 19 22 23 26 27 16 17 20 21 24 25 28
...
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+6, 2*r*r-5*r+7, ..., 2*r*r-r-4, 2*r*r-r-3, 2*r*r-r.
MAPLE
T:=(n, k)->((k+n)^2-4*k+3-(-1)^n-(k+n)*(-1)^(k+n))/2: seq(seq(T(k, n-k), k=1..n-1), n=1..13); # Muniru A Asiru, Dec 06 2018
MATHEMATICA
T[n_, k_] := ((n+k)^2 - 4k + 3 - (-1)^n - (-1)^(n+k)(n+k))/2;
Table[T[n-k+1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Dec 06 2018 *)
PROG
(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)**i-(t+2)*(-1)**t)/2
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Boris Putievskiy, Feb 14 2013
STATUS
approved