login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A153334
Number of zig-zag paths from top to bottom of an n X n square whose color is that of the top right corner.
5
1, 1, 4, 8, 24, 52, 136, 296, 720, 1556, 3624, 7768, 17584, 37416, 83024, 175568, 383904, 807604, 1746280, 3657464, 7839216, 16357496, 34812144, 72407728, 153204064, 317777032, 669108496, 1384524656, 2903267040, 5994736336
OFFSET
1,3
FORMULA
a(n) = (n+1)2^(n-2) - 2(n-1)binomial(n-2,(n-2)/2) for n even, a(n) = (n+1)2^(n-2) - (n-1)binomial(n-1,(n-1)/2) for n odd.
MATHEMATICA
Table[If[Mod[n, 2]==0, (n+1)*2^(n-2)-2(n-1) Binomial[n-2, (n-2)/2], (n+1)*2^(n-2)-(n-1) Binomial[n-1, (n-1)/2]], {n, 1, 30}] (* Indranil Ghosh, Feb 19 2017 *)
PROG
(Python)
import math
def C(n, r):
....f=math.factorial
....return f(n)/f(r)/f(n-r)
def A153334(n):
....if n%2==0: return str(int((n+1)*2**(n-2)-2*(n-1)*C(n-2, (n-2)/2)))
....else: return str(int((n+1)*2**(n-2)-(n-1)*C(n-1, (n-1)/2))) # Indranil Ghosh, Feb 19 2017
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Joseph Myers, Dec 24 2008
STATUS
approved