login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A153335 Number of zig-zag paths from top to bottom of an n X n square whose color is not that of the top right corner. 5

%I #16 Feb 20 2017 00:27:56

%S 0,1,2,8,18,52,116,296,650,1556,3372,7768,16660,37416,79592,175568,

%T 371034,807604,1697660,3657464,7654460,16357496,34106712,72407728,

%U 150499908,317777032,658707896,1384524656,2863150440,5994736336

%N Number of zig-zag paths from top to bottom of an n X n square whose color is not that of the top right corner.

%H Indranil Ghosh, <a href="/A153335/b153335.txt">Table of n, a(n) for n = 1..1000</a>

%H Joseph Myers, <a href="http://www.polyomino.org.uk/publications/2008/bmo1-2009-q1.pdf">BMO 2008--2009 Round 1 Problem 1---Generalisation</a>

%F 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)binomial(n-1,(n-1)/2) for n odd.

%t 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) Binomial[n-1,(n-1)/2]],{n,1,30}] (* _Indranil Ghosh_, Feb 19 2017 *)

%o (Python)

%o import math

%o def C(n, r):

%o ....f=math.factorial

%o ....return f(n)/f(r)/f(n-r)

%o def A153335(n):

%o ....if n%2==0: return str(int((n+1)*2**(n-2)-2*(n-1)*C(n-2, (n-2)/2)))

%o ....else: return str(int((n+1)*2**(n-2)-(n)*C(n-1, (n-1)/2))) # _Indranil Ghosh_, Feb 19 2017

%o (PARI) a(n) = if (n % 2, (n+1)*2^(n-2) - n*binomial(n-1,(n-1)/2), (n+1)*2^(n-2) - 2*(n-1)*binomial(n-2,(n-2)/2)); \\ _Michel Marcus_, Feb 19 2017

%Y Cf. A102699, A153334, A153336, A153337, A153338.

%K easy,nonn

%O 1,3

%A _Joseph Myers_, Dec 24 2008

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 07:16 EDT 2024. Contains 371905 sequences. (Running on oeis4.)