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(2,1), T(2,2), T(1,2), T(1,3), T(3,1),
...
T(2,n-1), T(4,n-3), T(6,n-5), ..., T(n,1),
T(2,n), T(4,n-2), T(6,n-4), ..., T(n,2),
T(1,n), T(3,n-2), T(5,n-4), ..., T(n-1,2),
T(1,n+1), T(3,n-1), T(5,n-3), ..., T(n+1,1),
...
The order of the list elements of adjacent antidiagonals. Let m be a positive integer.
Movement by antidiagonal {T(1,2*m), T(2*m,1)} from T(2,2*m-1) to T(2*m,1) length of step is 2,
movement by antidiagonal {T(1,2*m+1), T(2*m+1,1)} from T(2,2*m) to T(2*m,2) length of step is 2,
movement by antidiagonal {T(1,2*m), T(2*m,1)} from T(1,2*m) to T(2*m-1,2) length of step is 2,
movement by antidiagonal {T(1,2*m+1), T(2*m+1,1)} from T(1,2*m+1) to T(2*m+1,1) length of step is 2.
Table contains:
row 5 accommodates elements A097080 in odd places,
row 7 accommodates elements A137882 in odd places,
row 10 accommodates elements A100038 in odd places,
row 14 accommodates elements A100039 in odd places;
column 7 accommodates elements A071355 in odd places,
column 9 accommodates elements |A147973| in even places,
column 10 accommodates elements A139570 in odd places,
column 13 accommodates elements A130861 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
T(n,k) = (2*k^2+(4*n-5)*k+2*n^2-3*n+2+(2+(-1)^k)*((1-(k+n-1)*(-1)^i)))/4.
a(n) = (2*j^2+(4*i-5)*j+2*i^2-3*i+2+(2+(-1)^j)*((1-(t+1)*(-1)^i)))/4, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor((sqrt(8*n-7) - 1)/2).
EXAMPLE
The start of the sequence as table:
1, 4, 5, 11, 13, 22, 25, 37, 41, 56, 61, ...
2, 3, 7, 9, 16, 19, 29, 33, 46, 51, 67, ...
6, 12, 14, 23, 26, 38, 42, 57, 62, 80, 86, ...
8, 10, 17, 20, 30, 34, 47, 52, 68, 74, 93, ...
15, 24, 27, 39, 43, 58, 63, 81, 87, 108, 115, ...
18, 21, 31, 35, 48, 53, 69, 75, 94, 101. 123, ...
28, 40, 44, 59, 64, 82, 88, 109, 116, 140, 148, ...
32, 36, 49, 54, 70, 76, 95, 102, 124, 132, 157, ...
45, 60, 65, 83, 89, 110, 117, 141, 149, 176, 185, ...
50, 55, 71, 77, 96, 103, 125, 133, 158, 167, 195, ...
66, 84, 90, 111, 118, 142, 150, 177, 186, 216, 226, ...
...
The start of the sequence as triangle array read by rows:
1;
4, 2;
5, 3, 6;
11, 7, 12, 8;
13, 9, 14, 10, 15;
22, 16, 23, 17, 24, 18;
25, 19, 26, 20, 27, 21, 28;
37, 29, 38, 30, 39, 31, 40, 32;
41, 33, 42, 34, 43, 35, 44, 36, 45;
56, 46, 57, 47, 58, 48, 59, 49, 60, 50;
61, 51, 62, 52, 63, 53, 64, 54, 65, 55, 66;
...
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, 2, 5, 3, 6;
11, 7,12, 8,13, 9,14,10,15;
22,16,23,17,24,18,25,19,26,20,27,21,28;
37,29,38,30,39,31,40,32,41,33,42,34,43,35,44,36,45;
56,46,57,47,58,48,59,49,60,50,61,51,62,52,63,53,64,54,65,55,66;
...
Row number r contains permutation numbers 4*r-3 from 2*r*r-5*r+4 to 2*r*r-r:
2*r*r-3*r+2,2*r*r-5*r+4, 2*r*r-3*r+3, 2*r*r-5*r+5, 2*r*r-3*r+4, 2*r*r-5*r+6, ..., 2*r*r-3*r+1, 2*r*r-r.
...
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=(2*j**2+(4*i-5)*j+2*i**2-3*i+2+(2+(-1)**j)*((1-(t+1)*(-1)**i)))/4
CROSSREFS
Cf. A210521, A001844, A084849, A130883, A058331, A051890, A096376, A033816, A005893, A100037, A093328, A097080, A137882, A100038, A100039, A093005, A000384, A001105, A046092, A014105, A105638, A014106, A056220, A142463, A014107, A091823, A054000, A090288, A168244, A059993, A033537, A071355, A147973, A139570, A130861.
KEYWORD
nonn,tabl
AUTHOR
Boris Putievskiy, Feb 04 2013
STATUS
approved