OFFSET
1,2
COMMENTS
A triangle such that (1) every positive integer occurs exactly once; (2) row n consists of n consecutive numbers; (3) odd-numbered rows are increasing; and (4) even-numbered rows are decreasing.
Self-inverse permutation of the natural numbers.
Mirror image of triangle in A056023. - Philippe Deléham, Apr 04 2009
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. - Boris Putievskiy, Dec 24 2012
LINKS
Reinhard Zumkeller, Rows n = 1..125 of table, flattened
Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
Eric W. Weisstein, MathWorld: Pairing functions
FORMULA
a(n) = ((i+j-1)*(i+j-2)+((-1)^t+1)*i - ((-1)^t-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). - Boris Putievskiy, Dec 24 2012
EXAMPLE
The start of the sequence as a table:
1, 3, 4, 10, 11, 21, ...
2, 5, 9, 12, 20, 23, ...
6, 8, 13, 19, 24, 34, ...
7, 14, 18, 25, 33, 40, ...
15, 17, 26, 32, 41, 51, ...
...
Enumeration by boustrophedonic ("ox-plowing") diagonal method. - Boris Putievskiy, Dec 24 2012
The start of the sequence as triangle array read by rows:
1;
3, 2;
4, 5, 6;
10, 9, 8, 7;
11, 12, 13, 14, 15;
...
MAPLE
A056011 := proc(n, k)
if type(n, 'even') then
A131179(n)-k+1 ;
else
A131179(n)+k-1 ;
end if;
end proc: # R. J. Mathar, Sep 05 2012
MATHEMATICA
Flatten[If[EvenQ[Length[#]], Reverse[#], #]&/@Table[c=(n(n+1))/2; Range[ c-n+1, c], {n, 20}]] (* Harvey P. Dale, Mar 25 2012 *)
With[{nn=20}, {#[[1]], Reverse[#[[2]]]}&/@Partition[ TakeList[ Range[ (nn(nn+1))/2], Range[nn]], 2]//Flatten] (* Harvey P. Dale, Oct 05 2021 *)
PROG
(Haskell)
a056011 n = a056011_tabl !! (n-1)
a056011_list = concat a056011_tabl
a056011_tabl = ox False a000027_tabl where
ox turn (xs:xss) = (if turn then reverse xs else xs) : ox (not turn) xss
a056011_row n = a056011_tabl !! (n-1)
-- Reinhard Zumkeller, Nov 08 2013
CROSSREFS
KEYWORD
AUTHOR
Clark Kimberling, Aug 01 2000
EXTENSIONS
New name from Peter Luschny, Apr 15 2023, based on Boris Putievskiy's comment
STATUS
approved