login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A224791 Triangle T(n,k) read by rows: left edge is 0, 1, 2, ... (cf. A001477); otherwise each entry is sum of entry to left and entries immediately above it to left and right, with 1 for the missing right term at right edge. 2

%I

%S 0,1,2,2,5,8,3,10,23,32,4,17,50,105,138,5,26,93,248,491,630,6,37,156,

%T 497,1236,2357,2988,7,50,243,896,2629,6222,11567,14556,8,65,358,1497,

%U 5022,13873,31662,57785,72342,9,82,505,2360,8879,27774,73309,162756

%N Triangle T(n,k) read by rows: left edge is 0, 1, 2, ... (cf. A001477); otherwise each entry is sum of entry to left and entries immediately above it to left and right, with 1 for the missing right term at right edge.

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

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

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

%e Triangle begins:

%e 0;

%e 1, 2;

%e 2, 5, 8;

%e 3, 10, 23, 32;

%e 4, 17, 50, 105, 138;

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

%p if k=0 then n

%p elif k=n then T(n,n-1) + T(n-1,n-1) + 1

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

%p fi

%p end:

%p seq(seq(T(n, k), k=0..n), n=0..12); # _G. C. Greubel_, Nov 12 2019

%t T[n_, k_]:= T[n, k]= If[k==0, n, If[k==n , T[n, n-1] + T[n-1, n-1] + 1, T[n, k-1] + T[n-1, k-1] + T[n-1, k]]]; Table[T[n, k], {n, 0, 12}, {k, 0, n}]//Flatten (* _G. C. Greubel_, Nov 12 2019 *)

%o (Haskell)

%o a224791 n k = a224791_tabl !! n !! k

%o a224791_row n = a224791_tabl !! n

%o a224791_tabl = iterate

%o (\row -> scanl1 (+) $ zipWith (+) ([1] ++ row) (row ++ [1])) [0]

%o (PARI) T(n,k) = if(k==0, n, if(k==n, T(n,n-1) + T(n-1,n-1) + 1, T(n,k-1) + T(n-1,k-1) + T(n-1, k) )); \\ _G. C. Greubel_, Nov 12 2019

%o (Sage)

%o @CachedFunction

%o def T(n, k):

%o if (k==0): return n

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

%o else: return T(n,k-1) + 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 12 2019

%Y Cf. A051601, A059283.

%K nonn,tabl

%O 0,3

%A _Reinhard Zumkeller_, Apr 18 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 13 05:41 EDT 2020. Contains 336442 sequences. (Running on oeis4.)