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!)
A239835 Number of partitions of n such that the absolute value of the difference between the number of odd parts and the number of even parts is <=1. 6
1, 1, 1, 2, 2, 4, 4, 7, 8, 12, 15, 20, 26, 33, 44, 54, 71, 86, 113, 136, 175, 211, 268, 323, 403, 487, 601, 726, 885, 1068, 1292, 1556, 1867, 2244, 2678, 3208, 3809, 4547, 5379, 6398, 7542, 8937, 10506, 12404, 14542, 17110, 20011, 23465, 27381, 32006, 37267 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
COMMENTS
Number of partitions of n having an ordering of parts in which no parts of equal parity are adjacent, as in Example.
LINKS
FORMULA
a(n) = A045931(n) + A239833(n) for n >= 0.
a(n) = Sum_{k=-1..1} A240009(n,k). - Alois P. Heinz, Apr 01 2014
EXAMPLE
a(8) counts these 8 partitions: 8, 161, 521, 341, 4121, 323, 3212, 21212.
MAPLE
b:= proc(n, i, t) option remember; `if`(abs(t)-n>1, 0,
`if`(n=0, 1, `if`(i<1, 0, b(n, i-1, t)+
`if`(i>n, 0, b(n-i, i, t+(2*irem(i, 2)-1))))))
end:
a:= n-> b(n$2, 0):
seq(a(n), n=0..80); # Alois P. Heinz, Apr 01 2014
MATHEMATICA
p[n_] := p[n] = Select[IntegerPartitions[n], Abs[Count[#, _?OddQ] - Count[#, _?EvenQ]] <= 1 &]; t = Table[p[n], {n, 0, 10}]
TableForm[t] (* shows the partitions *)
Table[Length[p[n]], {n, 0, 60}] (* A239835 *)
(* Peter J. C. Moses, Mar 10 2014 *)
b[n_, i_, t_] := b[n, i, t] = If[Abs[t]-n>1, 0, If[n==0, 1, If[i<1, 0, b[n, i-1, t] + If[i>n, 0, b[n-i, i, t+(2*Mod[i, 2]-1)]]]]]; a[n_] := b[n, n, 0]; Table[a[n], {n, 0, 80}] (* Jean-François Alcover, Nov 16 2015, after Alois P. Heinz *)
CROSSREFS
Sequence in context: A014810 A318771 A363726 * A361860 A026929 A206560
KEYWORD
nonn,easy
AUTHOR
Clark Kimberling, Mar 29 2014
STATUS
approved

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 23:26 EDT 2024. Contains 371917 sequences. (Running on oeis4.)