I have the following questions: Let $N \in \mathbb{N}$ and \begin{equation} \sum_{i=1}^k n_i = N, \end{equation} with $n_i \in \mathbb{N}$ for $1 \le i \le k$ and some $k \in \mathbb{N}$, be an integer partition of $N$, such that $n_i \le p$ and for all non-empty subsets $I \subset \{1,\ldots,k\}$ we either have \begin{equation} \sum_{i \in I} n_i \notin p \mathbb{N} \end{equation} or \begin{equation} n_i = p, \;\;\;\;\;\;\;\; \forall i \in I. \end{equation} (I.e., in words, any subset sum is not a multiple of $p$ except it consists of the number $p$ only). How can I generate these partitions efficiently? Is there a closed expression for the number of such partitions?

For example, for $N=16$ and $p = 5$ I count the following 5 partitions: \begin{equation} \begin{split} 5+5+5+1 &= 16, \\ 5+5+4+2 &= 16, \\ 5+5+3+3 &= 16, \\ 5+4+4+3 &= 16, \\ 4+4+4+4 &= 16. \\ \end{split} \end{equation}

2more comments