login
Triangle read by rows: T(n,1) = T(n,n) = n and for 1<k<n: T(n,k) = floor((T(n-1,k-1)+T(n-1,k))/2).
2

%I #12 Mar 04 2019 12:39:07

%S 1,2,2,3,2,3,4,2,2,4,5,3,2,3,5,6,4,2,2,4,6,7,5,3,2,3,5,7,8,6,4,2,2,4,

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

%U 12,10,8,6,4,2,2,4,6,8,10,12,13,11,9,7,5,3,2,3,5,7,9,11,13,14,12,10,8,6,4,2,2,4,6,8,10,12,14

%N Triangle read by rows: T(n,1) = T(n,n) = n and for 1<k<n: T(n,k) = floor((T(n-1,k-1)+T(n-1,k))/2).

%C For n>1: sum of n-th row = A007590(n+1).

%H Robert Israel, <a href="/A101037/b101037.txt">Table of n, a(n) for n = 1..10011</a> (rows 1 to 141, flattened)

%F From _Robert Israel_, Jan 30 2018: (Start)

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

%F T(n,(n+1)/2) = 2 if n>1 is odd.

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

%F G.f. as triangle: x*y*(x^6*y^3-2*x^5*y^3-2*x^5*y^2+x^4*y^3+3*x^4*y^2+x^4*y-3*x^2*y+1)/((1-x^2*y)*(1-x)^2*(1-x*y)^2)).

%F (End)

%e Triangle begins:

%e 1;

%e 2, 2;

%e 3, 2, 3;

%e 4, 2, 2, 4;

%e 5, 3, 2, 3, 5;

%e 6, 4, 2, 2, 4, 6;

%e 7, 5, 3, 2, 3, 5, 7;

%e ...

%p T:= proc(n,k) if k < (n+1)/2 then n-2*k+2 elif k=(n+1)/2 then 2 else 2*k-n fi end proc:

%p T(1,1):= 1:

%p seq(seq(T(n,k),k=1..n),n=1..20); # _Robert Israel_, Jan 30 2018

%t T[n_, 1] := n; T[n_, n_] := n; T[n_, k_] := T[n, k] = Which[k < (n + 1)/2, n - 2*k + 2, k == (n + 1)/2, 2, True, 2*k - n];

%t Table[T[n, k], {n, 1, 13}, {k, 1, n}] // Flatten (* _Jean-François Alcover_, Mar 04 2019 *)

%K nonn,tabl

%O 1,2

%A _Reinhard Zumkeller_, Nov 27 2004