OFFSET
0,7
COMMENTS
For n > 2, T(n,k) is the number of integer strings s(0), ..., s(n) such that s(n) = n - k, s(0) = 0, |s(i) - s(i-1)| = 1 for i = 1,2 and <= 1 for i >= 3.
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1874 [a(676) ff. corrected by Georg Fischer, Jun 24 2020]
FORMULA
T(n, k) = T(n-1, k-2) + T(n-1, k-1) + T(n-1, k), starting with [1], [1, 0, 1], [1, 0, 2, 0, 1].
G.f.: y*z + (1-y*z)^2 / (1-z*(1+y+y^2)). - Ralf Stephan, Jan 09 2005 [corrected by Peter Luschny, Jun 25 2020]
EXAMPLE
1
1 0 1
1 0 2 0 1
1 1 3 2 3 1 1
1 2 5 6 8 6 5 2 1
1 3 8 13 19 20 19 13 8 3 1
MAPLE
A024996 := proc(n, k)
option remember;
if n < 0 or k < 0 or k > 2*n then
0 ;
elif n <= 2 then
if k = 2*n or k = 0 then
1;
elif k = 2*n-1 or k = 1 then
0;
elif k =2 then
2;
end if;
else
procname(n-1, k-1)+procname(n-1, k-2)+procname(n-1, k) ;
end if;
end proc: # R. J. Mathar, Jun 23 2013
seq(seq(A024996(n, k), k=0..2*n), n=0..11); # added by Georg Fischer, Jun 24 2020
MATHEMATICA
nmax = 10; CoefficientList[CoefficientList[Series[y*x + (1 - y*x)^2/(1 - x*(1 + y + y^2)), {x, 0, nmax}, {y, 0, 2*nmax}], x], y] // Flatten (* G. C. Greubel, May 22 2017; amended by Georg Fischer, Jun 24 2020 *)
PROG
(PARI) T(n, k)=if(n<0||k<0||k>2*n, 0, if(n==0, 1, if(n==1, [1, 0, 1][k+1], if(n==2, [1, 0, 2, 0, 1][k+1], T(n-1, k-2)+T(n-1, k-1)+T(n-1, k))))) \\ Ralf Stephan, Jan 09 2004
nmax=8; for(n=0, nmax, for(k=0, 2*n, print1(T(n, k), ", "))) \\ added by _Georg Fischer, Jun 24 2020
(Julia)
using Nemo
function A024996Expansion(prec)
R, t = PolynomialRing(ZZ, "t")
S, x = PowerSeriesRing(R, prec+1, "x")
ser = divexact(x^2*t^3 + x^2*t + x*t - 1, x*t^2 + x*t + x - 1)
L = zeros(ZZ, prec^2)
for k ∈ 0:prec-1, n ∈ 0:2*k
L[k^2+n+1] = coeff(coeff(ser, k), n)
end
L
end
A024996Expansion(8) |> println # Peter Luschny, Jun 25 2020
CROSSREFS
KEYWORD
nonn,tabf,easy
AUTHOR
EXTENSIONS
Edited by Ralf Stephan, Jan 09 2004
Offset corrected by R. J. Mathar, Jun 23 2013
STATUS
approved