OFFSET
0,2
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (5,0,-30,25,55,-60,-30,36).
FORMULA
n=2m: (3^n+3^m)/2 -2^(n-1)+2^(m-1); n=2m+1: (3^n+3^m)/2 - 2^(n-1) +1.
G.f.: -(39*x^7-20*x^6-39*x^5+14*x^4+17*x^3-5*x^2-3*x+1) / ((x-1)*(x+1)*(2*x-1)*(3*x-1)*(2*x^2-1)*(3*x^2-1)). - Colin Barker, Jul 17 2013
EXAMPLE
For n=2 there are three walks that stay in one face and two that visit two faces.
MAPLE
a:= n-> `if`(irem(n, 2, 'm')=0,
(3^n+3^m)/2+2^(m-1), (3^n+3^m)/2+1) -2^(n-1):
seq(a(n), n=0..35); # Alois P. Heinz, Jul 17 2013
MATHEMATICA
a[n_?OddQ] := (3^n + 3^((n - 1)/2))/2 - 2^(n - 1) + 1; a[n_?EvenQ] := (3^n + 3^(n/2))/2 - 2^(n - 1) + 2^(n/2 - 1); Table[a[n], {n, 0, 22}] (* Jean-François Alcover, Jan 25 2013, from formula *)
LinearRecurrence[{5, 0, -30, 25, 55, -60, -30, 36}, {1, 2, 5, 12, 39, 111, 350, 1044}, 40] (* Harvey P. Dale, Oct 30 2015 *)
PROG
(Haskell)
a051436 n = (3 ^ n + 3 ^ m - 2 ^ n + (1 - r) * 2 ^ m) `div` 2 + r
where (m, r) = divMod n 2
-- Reinhard Zumkeller, Jun 30 2013
(PARI) a(n)=if(n%2, (3^n + 3^((n - 1)/2))/2 + 1, (3^n + 3^(n/2))/2 + 2^(n/2 - 1)) - 2^(n-1) \\ Charles R Greathouse IV, Feb 10 2017
CROSSREFS
KEYWORD
nonn,walk,nice,easy
AUTHOR
EXTENSIONS
Corrected by T. D. Noe, Nov 09 2006
STATUS
approved