OFFSET
1,7
COMMENTS
T(n, k) = number of strings s(0)..s(n) such that s(0) = 0, s(n) = n - k, |s(i)-s(i-1)| <= 1 if s(i-1) is even, |s(i)-s(i-1)| = 1 if s(i-1) is odd, for 1 <= i <= n.
LINKS
EXAMPLE
First 5 rows:
1
1 1 1
1 1 3 1 1
1 2 4 5 4 2 1
1 2 7 7 13 7 7 2 1
MATHEMATICA
z = 12; t[n_, 0] := 1; t[n_, 1] := Floor[(n + 1)/2]; t[n_, k_] := t[n, k] = Which[k == 2 n, 1, k == 2 n - 1, Floor[(n + 1)/2], EvenQ[n + k], t[n - 1, k - 2] + t[n - 1, k - 1] + t[n - 1, k], OddQ[n + k], t[n - 1, k - 2] + t[n - 1, k]]; u = Table[t[n, k], {n, 0, z}, {k, 0, 2 n}];
TableForm[u] (* A026568 array *)
Flatten[u] (* A026568 sequence *)
PROG
(PARI) T(k, n)=if(n<0||n>2*k, 0, if(n==0||n==2*k, 1, if(k>0&&(n==1||n==2*k-1), (k+1)\2, T(k-1, n-2)+T(k-1, n)+if((k+n)%2==0, T(k-1, n-1))))) \\ Ralf Stephan
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
EXTENSIONS
Updated by Clark Kimberling, Aug 28 2014
STATUS
approved