TITLE: Composition of n into k parts, one part is odd and the rest are even
QUESTION [0 upvotes]: My task is to determine the number of compositions of $n$ into $k$ parts, such that exactly one part is odd and the rest are positive and even. I am trying to determine the set itself that I am finding the generating function for. Thus, I think my set is the following:
$S = (1,3,...Floor[(n+1)/2]) \times (2,4,...Floor[n/2]) \times ....... \times(2,4,...Floor[n/2]) $
where there are k-1 of the second type. Is this the correct set?
Thanks!

REPLY [0 votes]: That Cartesian product includes $k$-tuples whose sums are not equal to $n$ and misses some whose sums are equal to $n$. When $n=7$ and $k=3$, for instance, you have
$$\{1,3\}\times\{2\}\times\{2\}=\{\langle 1,2,2\rangle,\langle 3,2,2\rangle\}\;;$$
you don’t want $\langle 1,2,2\rangle$, and you do want $\langle 1,2,6\rangle$, for instance.
You’re thinking in the right direction, but since you’re working with generating functions, you really don’t need to worry about the upper bounds, and one point of using generating functions is to avoid having to work out the exact composition of the set that you’re trying to count. Here your generating function is simply
$$\left(\sum_{\ell\ge 1}x^{2\ell+1}\right)\left(\sum_{\ell\ge 1}x^{2\ell}\right)^{k-1}\;.$$
Of course you still have to convert this to a more usable form.
{"set_name": "stack_exchange", "score": 0, "question_id": 1250328}