login
Table T(n,k) = max{n+k-1, n+k-1} n, k > 0, read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1).
2

%I #25 Feb 16 2022 01:59:07

%S 1,2,3,2,3,4,5,4,3,4,5,6,7,6,5,4,5,6,7,8,9,8,7,6,5,6,7,8,9,10,11,10,9,

%T 8,7,6,7,8,9,10,11,12,13,12,11,10,9,8,7,8,9,10,11,12,13,14,15,14,13,

%U 12,11,10,9,8,9,10,11,12,13,14,15,16,17,16,15,14

%N Table T(n,k) = max{n+k-1, n+k-1} n, k > 0, read by sides of squares from T(1,n) to T(n,n), then from T(n,n) to T(n,1).

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

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

%F In general, let m be a natural number. Table T(n,k) = max{m*n+k-m, n+m*k-m}. For the general case,

%F a(n) = (m+1)*sqrt(n-1) + 1 - |n - floor(sqrt(n-1))^2 - floor(sqrt(n-1))|.

%F For m=1,

%F a(n) = 2*sqrt(n-1) + 1 - |n - floor(sqrt(n-1))^2 - floor(sqrt(n-1))|.

%F a(n) = t + |t^2 - n|, where t = floor(sqrt(n)+1/2). - _Ridouane Oudra_, May 07 2019

%e The start of the sequence as a table for the general case:

%e 1 m+1 2*m+1 3*m+1 4*m+1 5*m+1 6*m+1 ...

%e m+1 m+2 2*m+2 3*m+2 4*m+2 5*m+2 6*m+2 ...

%e 2*m+1 2*m+2 2*m+3 3*m+3 4*m+3 5*m+3 6*m+3 ...

%e 3*m+1 3*m+2 3*m+3 3*m+4 4*m+4 5*m+4 6*m+4 ...

%e 4*m+1 4*m+2 4*m+3 4*m+4 4*m+5 5*m+5 6*m+5 ...

%e 5*m+1 5*m+2 5*m+3 5*m+4 5*m+5 5*m+6 6*m+6 ...

%e 6*m+1 6*m+2 6*m+3 6*m+4 6*m+5 6*m+6 6*m+7 ...

%e ...

%e The start of the sequence as a triangular array read by rows for general case:

%e 1;

%e m+1, m+2, m+1;

%e 2*m+1, 2*m+2, 2*m+3, 2*m+2, 2*m+1;

%e 3*m+1, 3*m+2, 3*m+3, 3*m+4, 3*m+3, 3*m+2, 3*m+1;

%e 4*m+1, 4*m+2, 4*m+3, 4*m+4, 4*m+5, 4*m+4, 4*m+3, 4*m+2, 4*m+1;

%e ...

%e Row r contains 2*r-1 terms: r*m+1, r*m+2, ... r*m+r, r*m+r+1, r*m+r, ..., r*m+2, r*m+1.

%e The start of the sequence as triangle array read by rows for m=1:

%e 1;

%e 2, 3, 2;

%e 3, 4, 5, 4, 3;

%e 4, 5, 6, 7, 6, 5, 4;

%e 5, 6, 7, 8, 9, 8, 7, 6, 5;

%e 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6;

%e 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7;

%e ...

%o (Python)

%o result = 2*int(math.sqrt(n-1)) - abs(n-int(math.sqrt(n-1))**2 - int(math.sqrt(n-1)) -1) +1

%Y Cf. A187760.

%K nonn,tabf

%O 1,2

%A _Boris Putievskiy_, Jan 18 2013