login
A056011
Enumeration of natural numbers by the boustrophedonic diagonal method.
22
1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66
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
For generalizations see A218890, A213927. - Boris Putievskiy, Mar 10 2013
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
Cf. A079826, A131179 (first column), A218890, A213927.
Sequence in context: A113001 A036812 A039906 * A117123 A116966 A182187
KEYWORD
nonn,tabl,nice,easy
AUTHOR
Clark Kimberling, Aug 01 2000
EXTENSIONS
New name from Peter Luschny, Apr 15 2023, based on Boris Putievskiy's comment
STATUS
approved