OFFSET
1,3
COMMENTS
a(n) is the number of trails from 1 to n in an undirected graph with vertex set {1, 2, ..., n}, where i and j are adjacent if and only if |i-j|=1 or |i-j|=2. A trail can visit the same vertex more than once, but it cannot repeat an edge.
LINKS
StackExchange, Counting trails in a triangular grid
Index entries for linear recurrences with constant coefficients, signature (3, 1, -3, -2).
FORMULA
a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3) - 2*a(n-4) for n > 4.
G.f.: x*(1-2*x-2*x^2)/(1-3x-x^2+3*x^3+2*x^4).
EXAMPLE
For n = 5 there are 9 trails: 12345, 1235, 12435, 1245, 132435, 13245, 134235, 1345, and 135.
MAPLE
a := [1, 1, 2, 4, seq(0, i = 1 .. 36)]: for n from 5 to 40 do a[n] := 3*a[n-1]+a[n-2]-3*a[n-3]-2*a[n-4] end do; a;
MATHEMATICA
a[1] = 1; a[2] = 1; a[3] = 2; a[4] = 4; a[n_] := a[n] = 3 a[n - 1] + a[n - 2] - 3 a[n - 3] - 2 a[n - 4]; Table[a[n], {n, 1, 40}]
LinearRecurrence[{3, 1, -3, -2}, {1, 1, 2, 4}, 30] (* Harvey P. Dale, May 24 2011 *)
CROSSREFS
KEYWORD
nonn,easy,walk
AUTHOR
David Radcliffe, May 07 2011
STATUS
approved