A209293 Inverse permutation of A185180.
1, 2, 3, 5, 4, 6, 8, 9, 7, 10, 13, 12, 14, 11, 15, 18, 19, 17, 20, 16, 21, 25, 24, 26, 23, 27, 22, 28, 32, 33, 31, 34, 30, 35, 29, 36, 41, 40, 42, 39, 43, 38, 44, 37, 45, 50, 51, 49, 52, 48, 53, 47, 54, 46, 55, 61, 60, 62, 59, 63, 58, 64, 57, 65, 56, 66, 72, 73, 71, 74, 70, 75, 69, 76, 68, 77, 67
Offset: 1
Examples
The start of the sequence as table: 1....2...5...8..13..18...25...32...41... 3....4...9..12..19..24...33...40...51... 6....7..14..17..26..31...42...49...62... 10..11..20..23..34..39...52...59...74... 15..16..27..30..43..48...63...70...87... 21..22..35..38..53..58...75...82..101... 28..29..44..47..64..69...88...95..116... 36..37..54..57..76..81..102..109..132... 45..46..65..68..89..94..117..124..149... . . . The start of the sequence as triangle array read by rows: 1; 2,3; 5,4,6; 8,9,7,10; 13,12,14,11,15; 18,19,17,20,16,21; 25,24,26,23,27,22,28; 32,33,31,34,30,35,29,36; 41,40,42,39,43,38,44,37,45; . . . Row number r contains permutation from r numbers: if r is odd ceiling(r^2/2), ceiling(r^2/2)+1, ceiling(r^2/2)-1, ceiling(r^2/2)+2, ceiling(r^2/2)-2,...r*(r+1)/2; if r is even ceiling(r^2/2), ceiling(r^2/2)-1, ceiling(r^2/2)+1, ceiling(r^2/2)-2, ceiling(r^2/2)+2,...r*(r+1)/2;
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
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Mathematica
max = 10; row[n_] := Table[Ceiling[(n + k - 1)^2/2] + If[OddQ[k], 1, -1]*Floor[n/2], {k, 1, max}]; t = Table[row[n], {n, 1, max}]; Table[t[[n - k + 1, k]], {n, 1, max}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Jan 17 2013 *)
-
Python
t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n m1=int((i+j)/2)+int(i/2)*(-1)**(i+t+1) m2=int((i+j+1)/2)+int(i/2)*(-1)**(i+t) m=(m1+m2-1)*(m1+m2-2)/2+m1
Formula
As table T(n,k) read by antidiagonals
T(n,k) = n*n/2+4*(floor((k-1)/2)+1)*n+ceiling((k-1)^2/2), n,k > 0.
As linear sequence
a(n) = (m1+m2-1)*(m1+m2-2)/2+m1, where
m1 = int((i+j)/2)+int(i/2)*(-1)^(i+t+1),
m2 = int((i+j+1)/2)+int(i/2)*(-1)^(i+t),
t = int((math.sqrt(8*n-7) - 1)/ 2),
i = n-t*(t+1)/2,
j = (t*t+3*t+4)/2-n.
Comments