OFFSET
0,2
COMMENTS
It seems that these are partitions of odd length and sum, ranked by A340931. The parts do not have to be odd. - Gus Wiseman, Apr 06 2021
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..5000
V. I. Arnold, On teaching mathematics
FORMULA
a(n) = A027193(2n+1).
EXAMPLE
From Gus Wiseman, Apr 06 2021: (Start)
The a(0) = 1 through a(4) = 16 partitions:
(1) (3) (5) (7) (9)
(111) (221) (322) (333)
(311) (331) (432)
(11111) (421) (441)
(511) (522)
(22111) (531)
(31111) (621)
(1111111) (711)
(22221)
(32211)
(33111)
(42111)
(51111)
(2211111)
(3111111)
(111111111)
(End)
MAPLE
b:= proc(n, i) option remember; `if`(n=0, [1, 0$3],
`if`(i<1, [0$4], b(n, i-1)+`if`(i>n, [0$4], (p->
`if`(irem(i, 2)=0, [p[3], p[4], p[1], p[2]],
[p[2], p[1], p[4], p[3]]))(b(n-i, i)))))
end:
a:= n-> b(2*n+1$2)[2]:
seq(a(n), n=0..40); # Alois P. Heinz, Feb 16 2014
MATHEMATICA
b[n_, i_] := b[n, i] = If[n==0, {1, 0, 0, 0}, If[i<1, {0, 0, 0, 0}, b[n, i-1] + If[i>n, {0, 0, 0, 0}, Function[{p}, If[Mod[i, 2]==0, p[[{3, 4, 1, 2}]], p[[{2, 1, 4, 3}]]]][b[n-i, i]]]]]; a[n_] := b[2*n+1, 2*n+1][[2]]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, Jul 01 2015, after Alois P. Heinz *)
(* Slow but easy to read *)
a[n_] := Length@IntegerPartitions[2 n + 1, {1, 2 n + 1, 2}]
a /@ Range[0, 25]
(* Leo C. Stein, Nov 11 2020 *)
(* Faster, don't build the partitions themselves *)
(* Number of partitions of n into exactly k parts *)
P[0, 0] = 1;
P[n_, k_] := 0 /; ((k <= 0) || (n <= 0))
P[n_, k_] := P[n, k] = P[n - k, k] + P[n - 1, k - 1]
a[n_] := Sum[P[2 n + 1, k], {k, 1, 2 n + 1, 2}]
a /@ Range[0, 40]
(* Leo C. Stein, Nov 11 2020 *)
PROG
(Python)
# Could be memoized for speedup
def numoddpart(n, m=1):
"""The number of partitions of n into an odd number of parts of size at least m"""
if n < m:
return 0
elif n == m:
return 1
else:
# 1 (namely n = n) and all partitions of the form
# k + even partitions that start with >= k
return 1 + sum([numevenpart(n - k, k) for k in range(m, n//3 + 1)])
def numevenpart(n, m=1):
"""The number of partitions of n into an even number of parts of size at least m"""
if n < 2*m:
return 0
elif n == 2*m:
return 1
else:
return sum([numoddpart(n - k, k) for k in range(m, n//2 + 1)])
[numoddpart(n) for n in range(1, 70, 2)]
(Python)
# dict to memoize
ps = {(0, 0): 1}
def p(n, k):
"""Number of partitions of n into exactly k parts"""
if (n, k) in ps: return ps[(n, k)]
if (n<=0) or (k<=0): return 0
ps[(n, k)] = p(n-k, k) + p(n-1, k-1)
return ps[(n, k)]
def a(n): return sum([p(2*n+1, k) for k in range(1, 2*n+3, 2)])
[a(n) for n in range(0, 41)]
# Leo C. Stein, Nov 11 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Utpal Sarkar (doetoe(AT)gmail.com), May 26 2009
STATUS
approved