A185180 Enumeration table T(n,k) by antidiagonals. The order of the list is symmetrical movement from center to edges diagonal.
1, 2, 3, 5, 4, 6, 9, 7, 8, 10, 14, 12, 11, 13, 15, 20, 18, 16, 17, 19, 21, 27, 25, 23, 22, 24, 26, 28, 35, 33, 31, 29, 30, 32, 34, 36, 44, 42, 40, 38, 37, 39, 41, 43, 45, 54, 52, 50, 48, 46, 47, 49, 51, 53, 55, 65, 63, 61, 59, 57, 56, 58, 60, 62, 64, 66, 77, 75
Offset: 1
Examples
The start of the sequence as table: 1....2....5....9...14...20...27 ... 3....4....7...12...18...25...33 ... 6....8...11...16...23...31...40 ... 10..13...17...22...29...38...48 ... 15..19...24...30...37...46...57 ... 21..26...32...39...47...56...67 ... 28..34...41...49...58...68...79 ... ... The start of the sequence as triangle array read by rows: 1; 2, 3; 5, 4, 6; 9, 7, 8, 10; 14, 12, 11, 13, 15; 20, 18, 16, 17, 19, 21; 27, 25, 23, 22, 24, 26, 28; . . . Row number k (k > 1) of the triangle contains a permutation of the set of k numbers from (k^2-k+2)/2, (k^2-k+2)/2 + 1 ,...up to (k^2+k-2)/2 + 1, namely (k^2+k-2)/2, (k^2+k-2)/2 -2,...,(k^2-k+2)/2, (k^2-k+2)/2 + 2,..., (k^2+k-2)/2-1, (k^2+k-2)/2+1.
Links
- Boris Putievskiy, Rows n = 1..140 of triangle, flattened
- Boris Putievskiy, Transformations Integer Sequences And Pairing Functions, arXiv:1212.2732 [math.CO], 2012.
- Eric W. Weisstein's World of Mathematics, Pairing functions
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Mathematica
a[n_] := Module[{i, j, t}, i = n - t(t+1)/2; j = (t^2 + 3t + 4)/2 - n; t = Floor[(-1 + Sqrt[8n - 7])/2]; If[j <= i, (i(i+1) + (j-1)(j + 2i - 4))/2, (i(i+1) + (j-1)(j + 2i - 4))/2 + 2(j-i) - 1]]; Array[a, 68] (* Jean-François Alcover, Nov 21 2018, from Python *)
-
Python
t=int((math.sqrt(8*n-7) - 1)/ 2) i=n-t*(t+1)/2 j=(t*t+3*t+4)/2-n if j<=i: m=(i*(i+1) + (j-1)*(j+2*i-4))/2 else: m=(i*(i+1) + (j-1)*(j+2*i-4))/2 +2*(j-i)-1
Formula
a(n) = (i*(i+1) + (j-1)*(j+2*i-4))/2, if j<=i, a(n)=(i*(i+1) + (j-1)*(j+2*i-4))/2 +2*(j-i)-1, if j>i, where i=n-t*(t+1)/2, j=(t*t+3*t+4)/2-n, t=floor[(-1+sqrt(8*n-7))/2].
Comments