 <p>There's actually a really simple solution to this: the number of partitions of <code>n</code> that contain a <code>1</code> equals the total number of partitions of <code>(n - 1)</code>. One way to think of it is imagining removing one <code>1</code> from each of the partitions of <code>n</code> that contain one; any partition of <code>n</code> that does not contain a <code>1</code> cannot be transformed in such a way.</p> <p>So we can simply remove the first term from the classic <a href="https://en.wikipedia.org/wiki/Partition_%28number_theory%29#Recurrence_formula" rel="nofollow">partition recurrence</a>, <code>p(k) = p(k − 1) + p(k − 2) − p(k − 5) − p(k − 7) + p(k − 12) + p(k − 15) − p(k − 22) − ...</code>, and derive:</p> <pre><code>p_without_1s(k) = p(k − 2) − p(k − 5) − p(k − 7) + p(k − 12) + p(k − 15) − p(k − 22) − ... </code></pre> <p>Or</p> <pre><code>p_without_1s(k) = p(k) - p(k - 1) </code></pre>