A056023 The positive integers written as a triangle, where row n is written from right to left if n is odd and otherwise from left to right.
1, 2, 3, 6, 5, 4, 7, 8, 9, 10, 15, 14, 13, 12, 11, 16, 17, 18, 19, 20, 21, 28, 27, 26, 25, 24, 23, 22, 29, 30, 31, 32, 33, 34, 35, 36, 45, 44, 43, 42, 41, 40, 39, 38, 37, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56
Offset: 1
Examples
From _Philippe Deléham_, Apr 04 2009 (Start) Triangle begins: 1; 2, 3; 6, 5, 4; 7, 8, 9, 10; 15, 14, 13, 12, 11; ... (End) Enumeration by boustrophedonic ("ox-plowing") diagonal method. - _Boris Putievskiy_, Dec 24 2012
Links
- Ivan Neretin, Table of n, a(n) for n = 1..5050
- Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
- Eric Weisstein's MathWorld, Pairing functions
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Mathematica
(* As a rectangle: *) r[n_, k_] := n + (k + n - 2) (k + n - 1)/2/; OddQ[n + k]; r[n_, k_] := k + (n + k - 2) (n + k - 1)/2/; EvenQ[n+k]; TableForm[Table[f[n, k], {n, 1, 10}, {k, 1, 15}]] Table[r[n - k + 1, k], {n, 14}, {k, n, 1, -1}]//Flatten (* Clark Kimberling, Feb 03 2011 *) Module[{nn=15},If[OddQ[Length[#]],Reverse[#],#]&/@TakeList[Range[ (nn(nn+1))/2],Range[nn]]]//Flatten (* Harvey P. Dale, Feb 08 2022 *)
Formula
T(n, k) = (n^2 - (n - 2*k)*(-1)^(n mod 2))/2 + n mod 2. - Reinhard Zumkeller, Apr 25 2004
a(n) = ((i + j - 1)*(i + j - 2) + ((-1)^t + 1)*j - ((-1)^t - 1)*i)/2, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n and t=floor((-1+sqrt(8*n-7))/2). - Boris Putievskiy, Dec 24 2012
Extensions
Name edited by Andrey Zabolotskiy, Apr 16 2023
Comments