OFFSET
1,3
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..1000
Joseph Myers, BMO 2008--2009 Round 1 Problem 1---Generalisation
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)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) 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 A153335(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)*C(n-1, (n-1)/2))) # Indranil Ghosh, Feb 19 2017
(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
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Joseph Myers, Dec 24 2008
STATUS
approved