# Number of 1's among all partitions of an integer

I am trying find a recurrence relation for the number of 1's among all partitions of an integer. The OEIS database has an entry mentioning this particular sequence but does not give a recurrence relation. This leads me to the question: does a recurrence relation exist for this sequence or must one use series to find the generating function? If so, how would the generating function be found?

Thank you!

The generating function can be found by marking the ones in the standard partition generating function with an extra variable, call it $u.$ This gives $$G(z, u) = \frac{1}{1-uz} \prod_{k\ge 2} \frac{1}{1-z^k}.$$ It follows that the generating function of the number of ones is given by $$\left.\frac{d}{du} G(z, u) \right|_{u=1} = \left. -1 \times \frac{1}{(1-uz)^2} \times -z \times \prod_{k\ge 2} \frac{1}{1-z^k} \right|_{u=1} \\= \frac{z}{(1-z)^2} \prod_{k\ge 2} \frac{1}{1-z^k} = \frac{z}{1-z} \prod_{k\ge 1} \frac{1}{1-z^k}.$$ This is because for a term $q \times u^k z^n$ which represents $q$ instances of partitions of $n$ with $k$ ones in the bivariate generating function $G(z,u)$ the value $$\left. \frac{d}{du} q \times u^k z^n\right|_{u=1}$$ turns into $$q\times k \times z^n,$$ thereby summing the count of all the ones. I highly recommend you consult the OEIS sequence A000070 as it contains a great deal of useful information as you seem to have discovered.

You may note that we can see from this generating function that the value in question is the sum of the number of partitions of the integers from $0$ to $n-1.$ (That is what the multiplier $z/(1-z)$ does and it is applied to the partition generating function.)

I'm not sure why no one has mentioned the simplest, most obvious recurrence. Given $$f(n)$$ as the number of $$1$$'s among all partitions of $$n$$ and $$P(n)$$ as the number of partitions of $$n$$, then

$$f(1) = 1$$

$$f(n) = P(n-1) + f(n-1)$$

because we can add a $$1$$ to each partition of $$n-1$$ to generate all the partitions of $$n$$ that include a $$1$$.

since OP mentions an interest in recurrence relations, it may be a worthwhile exercise to supplement Marko's excellent answer with the following naive combinatorial argument.

let us define $\psi(n)$ to be the number of ones occurring in all partitions of $n$. we also define $P^n$ as the number of partitions of $n$ and $P_m^n$ as the number of partitions of $n$ containing exactly $m$ ones. clearly we must have $$\psi(n) = \sum_{k=0}^n k\;P_k^n$$

and also, for $0 \le m \le k$ $$P_k^n = P_{k-m}^{n-m}$$ giving $$\psi(n) = \sum_{k=1}^n k\;P_k^n \\ = \sum_{k=1}^n \sum_{m=1}^k P_k^n \\ = \sum_{m=1}^n \sum_{k=m}^n P_k^n \\ = \sum_{m=1}^n \sum_{k=0}^{n-m} P_k^{n-m} \\$$ as the sum of partitions containing all possible numbers of ones we have: $$\sum_{k=0}^{n-m} P_k^{n-m} = P^{n-m}$$ thus $$\psi(n) = \sum_{m=1}^n P^{n-m} \\ = \sum_{k=0}^{n-1} P^k$$ which agrees with the result Marko obtained using generating functions