OFFSET
1,3
COMMENTS
LINKS
Reinhard Zumkeller, Rows n = 1..120 of triangle, flattened
EXAMPLE
Triangle begins as:
1;
1, 2;
1, 5, 3;
1, 11, 11, 4;
1, 23, 33, 19, 5;
1, 47, 89, 71, 29, 6;
...
MAPLE
T:= proc(n, k) option remember;
if k=1 then 1
elif k=n then n
else T(n-1, k-1) + 2*T(n-1, k)
fi
end:
seq(seq(T(n, k), k=1..n), n=1..12); # G. C. Greubel, Nov 13 2019
MATHEMATICA
T[n_, k_]:= T[n, k]= If[k==1, 1, If[k==n, n, T[n-1, k-1] + 2*T[n-1, k]]];
Table[T[n, k], {n, 12}, {k, n}]//Flatten (* G. C. Greubel, Nov 13 2019 *)
PROG
(Haskell)
a105728 n k = a105728_tabl !! (n-1) !! (k-1)
a105728_row n = a105728_tabl !! (n-1)
a105728_tabl = iterate (\row -> zipWith (+) ([0] ++ tail row ++ [1]) $
zipWith (+) ([0] ++ row) (row ++ [0])) [1]
-- Reinhard Zumkeller, Jul 22 2013
(Magma)
function T(n, k)
if k eq 1 then return 1;
elif k eq n then return n;
else return T(n-1, k-1) + 2*T(n-1, k);
end if;
return T;
end function;
[T(n, k): k in [1..n], n in [1..12]]; // G. C. Greubel, Nov 13 2019
(Sage)
@CachedFunction
def T(n, k):
if (k==1): return 1
elif (k==n): return n
else: return T(n-1, k-1) + 2*T(n-1, k)
[[T(n, k) for k in (1..n)] for n in (1..12)] # G. C. Greubel, Nov 13 2019
CROSSREFS
KEYWORD
nonn,tabl
AUTHOR
Reinhard Zumkeller, Apr 18 2005
STATUS
approved