login
Natural numbers placed in table T(n,k) layer by layer. The order of placement: T(n,n), T(n-1,n), T(n,n-1), ... T(1,n), T(n,1). Table T(n,k) read by antidiagonals.
4

%I #22 Nov 05 2025 15:22:22

%S 1,3,4,8,2,9,15,6,7,16,24,13,5,14,25,35,22,11,12,23,36,48,33,20,10,21,

%T 34,49,63,46,31,18,19,32,47,64,80,61,44,29,17,30,45,62,81,99,78,59,42,

%U 27,28,43,60,79,100,120,97,76,57,40,26,41,58,77,98,121

%N Natural numbers placed in table T(n,k) layer by layer. The order of placement: T(n,n), T(n-1,n), T(n,n-1), ... T(1,n), T(n,1). Table T(n,k) read by antidiagonals.

%C Permutation of the natural numbers.

%C 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.

%C Layer is pair of sides of square from T(1,n) to T(n,n) and from T(n,n) to T(n,1). Enumeration table T(n,k) is layer by layer. The order of the list:

%C T(1,1)=1;

%C T(2,2), T(1,2), T(2,1);

%C ...

%C T(n,n), T(n-1,n), T(n,n-1), ... T(1,n), T(n,1);

%C ...

%H Boris Putievskiy, <a href="/A213922/b213922.txt">Rows n = 1..140 of triangle, flattened</a>

%H Boris Putievskiy, <a href="https://arxiv.org/abs/1212.2732">Transformations [of] Integer Sequences And Pairing Functions</a> arXiv:1212.2732 [math.CO], 2012.

%H Eric W. Weisstein, <a href="https://mathworld.wolfram.com/PairingFunction.html">MathWorld: Pairing functions</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F As a table,

%F T(n,k) = n*n - 2*k + 2, if n >= k;

%F T(n,k) = k*k - 2*n + 1, if n < k.

%F As a linear sequence,

%F a(n) = i*i - 2*j + 2, if i >= j;

%F a(n) = j*j - 2*i + 1, if i < j

%F where

%F i = n - t*(t+1)/2,

%F j = (t*t + 3*t + 4)/2 - n,

%F t = floor((-1 + sqrt(8*n-7))/2).

%e The start of the sequence as a table:

%e 1, 3, 8, 15, 24, 35, ...

%e 4, 2, 6, 13, 22, 33, ...

%e 9, 7, 5, 11, 20, 31, ...

%e 16, 14, 12, 10, 18, 29, ...

%e 25, 23, 21, 19, 17, 27, ...

%e 36, 34, 32, 30, 28, 26, ...

%e ...

%e The start of the sequence as triangular array read by rows:

%e 1;

%e 3, 4;

%e 8, 2, 9;

%e 15, 6, 7, 16;

%e 24, 13, 5, 14, 25;

%e 35, 22, 11, 12, 23, 36;

%e ...

%t f[n_, k_] := n^2 - 2*k + 2 /; n >= k; f[n_, k_] := k^2 - 2*n + 1 /; n < k; TableForm[Table[f[n, k], {n, 1, 5}, {k, 1, 10}]]; Table[f[n - k + 1, k], {n, 5}, {k, n, 1, -1}] // Flatten (* _G. C. Greubel_, Aug 19 2017 *)

%o (Python)

%o t=int((math.sqrt(8*n-7) - 1)/ 2)

%o i=n-t*(t+1)/2

%o j=(t*t+3*t+4)/2-n

%o if i >= j:

%o result=i*i-2*j+2

%o else:

%o result=j*j-2*i+1

%Y Cf. A060734, A060736; table T(n,k) contains: in rows A005563, A028872, A028875, A028881, A028560, A116711; in columns A000290, A008865, A028347, A028878, A028884.

%K nonn,tabl

%O 1,2

%A _Boris Putievskiy_, Mar 05 2013