login
Rows of triangle formed using Pascal's rule except begin and end n-th row with n+1.
15

%I #54 Oct 27 2023 22:00:44

%S 1,2,2,3,4,3,4,7,7,4,5,11,14,11,5,6,16,25,25,16,6,7,22,41,50,41,22,7,

%T 8,29,63,91,91,63,29,8,9,37,92,154,182,154,92,37,9,10,46,129,246,336,

%U 336,246,129,46,10,11,56,175,375,582,672,582,375,175,56,11

%N Rows of triangle formed using Pascal's rule except begin and end n-th row with n+1.

%C Row sums give A033484(n).

%C The number of spotlight tilings of an (m+1) X (n+1) rectangle, read by antidiagonals. - _Bridget Tenner_, Nov 09 2007

%C T(n,k) = A134636(n,k) - A051601(n,k). - _Reinhard Zumkeller_, Nov 23 2012

%C T(n,k) = A209561(n+2,k+1), 0 <= k <= n. - _Reinhard Zumkeller_, Dec 26 2012

%C For a closed-form formula for arbitrary left and right borders of Pascal like triangle see A228196. - _Boris Putievskiy_, Aug 19 2013

%C For a closed-form formula for generalized Pascal's triangle see A228576. - _Boris Putievskiy_, Sep 09 2013

%H Reinhard Zumkeller, <a href="/A051597/b051597.txt">Rows n = 0..120 of triangle, flattened</a>

%H B. E. Tenner, <a href="http://dx.doi.org/10.1007/s00026-011-0077-6">Spotlight tiling</a>, Ann. Combin. 14 (4) (2010) 553.

%H <a href="/index/Pas#Pascal">Index entries for triangles and arrays related to Pascal's triangle</a>

%F T(2n,n) = A051924(n+1). - _Philippe Deléham_, Nov 26 2006

%F T(m,n) = binomial(m+n,m) - binomial(m+n-2,m-1) (correct up to offset and transformation of square indices to triangular indices). - _Bridget Tenner_, Nov 09 2007

%F T(0,n) = T(n,0) = n+1, T(n,k) = T(n-1,k) + T(n-1,k-1), 0 < k < n.

%F From _Peter Bala_, Feb 28 2013: (Start)

%F T(n,k) = binomial(n,k-1) + binomial(n,k) + binomial(n,k+1) for 0 <= k <= n.

%F O.g.f.: (1 - xt^2)/((1 - t)(1 - xt)(1 - (1+x)t)) = 1 + (2 + 2x)t + (3 + 4x + 3x^2)t^2 + ....

%F Row polynomials: ((1+x+x^2)*(1+x)^n - 1 - x^(n+2))/x. (End)

%e Triangle begins as:

%e 1;

%e 2, 2;

%e 3, 4, 3;

%e 4, 7, 7, 4;

%e 5, 11, 14, 11, 5;

%p T:= proc(n, k) option remember;

%p `if`(k<0 or k>n, 0,

%p `if`(k=0 or k=n, n+1,

%p T(n-1, k-1) + T(n-1, k) ))

%p end:

%p seq(seq(T(n, k), k=0..n), n=0..14); # _Alois P. Heinz_, May 27 2013

%t NestList[Append[ Prepend[Map[Apply[Plus, #] &, Partition[#, 2, 1]], #[[1]] + 1], #[[1]] + 1] &, {1}, 10] // Grid (* _Geoffrey Critzer_, May 26 2013 *)

%t T[n_, k_] := T[n, k] = If[k<0 || k>n, 0, If[k==0 || k==n, n+1, T[n-1, k-1] + T[n-1, k]]]; Table[T[n, k], {n, 0, 14}, {k, 0, n}] // Flatten (* _Jean-François Alcover_, Jan 09 2016, after _Alois P. Heinz_ *)

%o (Haskell)

%o a051597 n k = a051597_tabl !! n !! k

%o a051597_row n = a051597_tabl !! n

%o a051597_tabl = iterate (\row -> zipWith (+) ([1] ++ row) (row ++ [1])) [1]

%o -- _Reinhard Zumkeller_, Nov 23 2012

%o (PARI) T(n,k) = if(k<0 || k>n, 0, if(k==0 || k==n, n+1, T(n-1, k-1) + T(n-1, k) ));

%o for(n=0, 12, for(k=0, n, print1(T(n,k), ", "))) \\ _G. C. Greubel_, Nov 18 2019

%o (Magma)

%o function T(n,k)

%o if k lt 0 or k gt n then return 0;

%o elif k eq 0 or k eq n then return n+1;

%o else return T(n-1,k-1) + T(n-1,k);

%o end if;

%o return T;

%o end function;

%o [T(n,k): k in [0..n], n in [0..12]]; // _G. C. Greubel_, Nov 18 2019

%o (Sage)

%o @CachedFunction

%o def T(n, k):

%o if (k<0 or k>n): return 0

%o elif (k==0 or k==n): return n+1

%o else: return T(n-1, k-1) + T(n-1, k)

%o [[T(n, k) for k in (0..n)] for n in (0..12)] # _G. C. Greubel_, Nov 18 2019

%o (GAP)

%o T:= function(n,k)

%o if k<0 or k>n then return 0;

%o elif k=0 or k=n then return n+1;

%o else return T(n-1,k-1) + T(n-1,k);

%o fi;

%o end;

%o Flat(List([0..12], n-> List([0..n], k-> T(n,k) ))); # _G. C. Greubel_, Nov 18 2019

%Y Stripped variant of A072405, A122218.

%Y Cf. A007318, A228196, A228576.

%K easy,nonn,tabl

%O 0,2

%A _Asher Auel_