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). Let m be natural number. The order of the list:
T(1,1)=1;
T(3,1), T(2,2), T(1,3);
T(2,1), T(1,2);
. . .
T(2*m+1,1), T(2*m,2), T(2*m-1,3),...T(1,2*m+1);
T(2*m,1), T(2*m-1,2), T(2*m-2,3),...T(1,2*m);
. . .
First row contains antidiagonal {T(1,2*m+1), ... T(2*m+1,1)}, read upwards.
Second row contains antidiagonal {T(1,2*m), ... T(2*m,1)}, read upwards.
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 table:
1....6...4..15..11..28..22...
5....3..14..10..27..21..44...
2...13...9..26..20..43..35...
12...8..25..19..42..34..63...
7...24..18..41..33..62..52...
23..17..40..32..61..51..86...
16..39..31..60..50..85..73...
. . .
The start of the sequence as triangle array read by rows:
1;
6,5;
4,3,2;
15,14,13,12;
11,10,9,8,7;
28,27,26,25,24,23;
22,21,20,19,18,17,16;
. . .
Row number r consecutive contains r numbers in decreasing order.
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-2*i+3-(t+1)*(1+2*(-1)**t))/2
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Boris Putievskiy, Feb 22 2013
STATUS
approved