How many compositions of n with k parts are there in which each part is a even number except that a 1 may occur as a part at most once? I need to find how many compositions of n with k parts are there in which each part is a even number except that a 1 may occur as a part at most once.
I have an example for the number of k-part compositions of n there are in which each part is an odd number and I'm assuming the solution is similar. Here is what I have so far
$$S=\{1\}(N_{even})^k$$
where $N_{even} = \{2,4,6,...\}$
$$\Phi_S(x) = \Phi_{\{1\}(N_{even})^k}(x)$$
$$\Phi_S(x) = x+(\sum\limits_{i\geq0}^{}x^{2i+2})^k$$
This is where I'm not sure I'm including the "1 may occur at least once" part correctly by adding the $x$. I'd appreciate any help on this!
 A: Method 1 (counting).
The number of compositions of $n$ is $2^{n-1}$, via standard stars and bars: a composition corresponds to lining up $n$ stars in a row, and inserting bars in any subset of the $n-1$ gaps.
Similarly, the number of compositions of $n$ into $k$ parts is $\binom{n-1}{k-1}$: choose $k-1$ of the $n-1$ gaps to insert bars in.
The compositions we care about for this question are those that either


*

*have all parts even: $n = 2a_1 + 2a_2 + \dots + 2a_k$, which corresponds via the observation that $n/2 = a_1 + a_2 + \dots + a_k$ to an arbitrary composition of $n/2$ into $k$ parts, whose number is $2^{n/2 - 1}$ (if $n$ is even, and $0$ otherwise).

*have exactly one part equal to $1$, and the other parts even: this can be either the first part ($n = 1 + 2a_1 + 2a_2 + \dots + 2a_{k-1}$) or the second part ($n = 2a_1 + 1 + 2a_2 + \dots + 2a_{k-1}$)... or any part up to the $k$th part ($n = 2a_1 + 2a_2 + \dots + 2a_{k-1} + 1$). Note that all these compositions are distinct. In each case, any such composition corresponds via the observation that $\frac{n - 1}{2} = a_1 + a_2 + \dots + a_{k-1}$ to an arbitrary partition of $\frac{n-1}{2}$ into $k-1$ parts, whose number is $\binom{(n-1)/2-1}{k-1}$ (if $n$ is odd, and $0$ otherwise).
So the answer is
$$\binom{n/2 - 1}{k-1}[n\text{ is even}] + k\binom{(n-1)/2 - 1}{k-1}[n\text{ is odd}].$$

Method 2 (generating functions).
Let $\mathcal{E}$ denote the class of all positive even numbers. We have a specification and consequent generating function for $\mathcal{E}$ as
$$\mathcal{E} = \operatorname{S\scriptsize EQ}_{\ge 1}(\mathcal{Z}\times\mathcal{Z})$$
$$E(z) = \frac{z^2}{1-z^2}$$
(Check that $E(z) = z^2 + z^4 + z^6 + \dots$ as expected.)
Let $\mathcal{C}$ denote the class of compositions of the kind we want. A specification for $\mathcal{C}$ is, considering the compositions with all parts even, and then with first part $1$, second part $1$, and so on:
$$
\mathcal{C} =
(\mathcal{E}\times\cdots\times\mathcal{E}) + (\mathcal{Z}\times\mathcal{E}\times\cdots\times\mathcal{E}) + (\mathcal{E}\times\mathcal{Z}\times\cdots\times\mathcal{E}) + \dots + (\mathcal{E}\times\cdots\times\mathcal{E}\times\mathcal{Z})
$$
which in simpler notation is
$$\mathcal{C} = (\mathcal{E}^k) + k(\mathcal{Z}\times\mathcal{E}^{k-1})$$
giving the generating function
$$C(z) = E(z)^k + kzE(z)^{k-1}$$
which with our previously found generating function $E(z)$ is
$$C(z) = \left(\frac{z^2}{1-z^2}\right)^k + kz\left(\frac{z^2}{1-z^2}\right)^{k-1}.$$

Note: it is possible to derive the coefficients from the generating function, or the generating function from the coefficients, but depending on what you're after (closed forms or asymptotics), it may not be worth going that route.
For example, from $C(z)$ we can get $C_n = [z^n]C(z)$ by calculating coefficients.
$$[z^n]\left(\frac{z^2}{1-z^2}\right)^k = [z^{n-2k}](1-z^2)^{-k} = [z^{n/2-k}](1-z)^{-k}[n\text{ is even}] = (-1)^{n/2-k}\binom{-k}{n/2-k}[n\text{ is even}] = \binom{n/2-1}{n/2-k}[n\text{ is even}] = \binom{n/2-1}{k-1}[n\text{ is even}]$$
(would be a bit faster if you know beforehand that $[z^n]\left(\frac{z}{1-z}\right)^r = \binom{n-1}{r-1}$) and similarly
$$[z^n]\left(kz(\frac{z^2}{1-z^2})^{k-1}\right)=k[z^{(n-1)/2}](\frac{z}{1-z})^{k-1}[n\text{ is odd}] = k\binom{(n-1)/2 - 1}{k-1}[n\text{ is odd}].$$
