A056011 Enumeration of natural numbers by the boustrophedonic diagonal method.
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
Examples
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; ...
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
- Index entries for sequences that are permutations of the natural numbers
Programs
-
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
-
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 *)
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
Extensions
New name from Peter Luschny, Apr 15 2023, based on Boris Putievskiy's comment
Comments