OFFSET
0,3
COMMENTS
More generally, the g.f. for the number of compositions such that part m occurs with even multiplicity is (1-x)/(1-2*x)*(1-2*x+x^m-x^(m+1))/(1-2*x+2*x^m-2*x^(m+1)). - Vladeta Jovovic, Sep 01 2007
LINKS
FORMULA
a(0) = 1, a(n) = 2^(n-2) + 2^((n-2)/2) if n is positive and even, otherwise a(n) = 2^(n-2) - 2^((n-3)/2).
G.f.: (1-z)*(1-z-z^2)/((1-2*z)*(1-2*z^2)). - Emeric Deutsch, Feb 03 2006
E.g.f.: (1 + exp(2*x) - sqrt(2)*sinh(x*sqrt(2)) + 2*cosh(x*sqrt(2)))/4. - Sergei N. Gladkovskii, Nov 18 2011
a(k) = (1/4)*0^k + (1/4)*2^k + (1/8)*(2-sqrt(2))*(sqrt(2))^k + (1/8)*(2+sqrt(2))*(-sqrt(2))^k. - Sergei N. Gladkovskii, Nov 18 2011
EXAMPLE
a(4)=6 because the compositions of 4 having an even number of 1's are 4,22,211,121,112 and 1111 (the other compositions of 4 are 31 and 13).
MAPLE
a:=proc(n) if n mod 2 = 0 then 2^(n-2)+2^((n-2)/2) else 2^(n-2)-2^((n-3)/2) fi end: seq(a(n), n=1..38); # Emeric Deutsch, Feb 01 2006
MATHEMATICA
f[n_] := If[ EvenQ[n], 2^(n - 2) + 2^((n - 2)/2), 2^(n - 2) - 2^((n - 3)/2)]; Array[f, 34] (* Robert G. Wilson v, Feb 01 2006 *)
PROG
(PARI) a(n) = n-=2; (n==-2) + 1<<n + if(n>=0, (-1)^n << (n>>1)); \\ Kevin Ryde, May 02 2023
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Vladeta Jovovic, Jan 31 2006
EXTENSIONS
More terms from Robert G. Wilson v and Emeric Deutsch, Feb 01 2006
a(0)=1 prepended and formulas corrected by Jason Yuen, Sep 09 2024
STATUS
approved