The question is this:

In how many partitions of $\{1,2,\ldots,n\}$ into three disjoint sets, $A$, $B$, and $C$, are there no two consecutive numbers in the set $A$?


  • $\begingroup$ Do you consider these ordered partitions, so that, for instance, $A=\{1,2\}$, $B=\{3\}$, $C=\{4\}$ does not qualify, but $A=\{3\}$, $B=\{1,2\}$, $C=\{4\}$ is okay? $\endgroup$ Feb 11, 2011 at 21:29
  • $\begingroup$ exactly, second exmpale is okay. $\endgroup$
    – user6163
    Feb 11, 2011 at 21:32

1 Answer 1


Number of ways of selecting $k$ numbers from $1,2,\dots,n$ such that no two are consecutive is

$\displaystyle \binom{n-k+1}{k}$, for instance see my answer here: Consecutive birthdays probability

Once you do that, count the number of partitions of the remaining into $B$ and $C$.

Which is given by $2S(n-k,2) + 2$ where $S(a,b)$ are the Stirling numbers of the second kind (for and explanation see the answer linked above).

Now I guess your answer is

$$\sum_{k=0}^{n} \binom{n-k+1}{k} (2S(n-k,2) + 2)$$

(Note: I haven't tried to confirm it, I leave that to you)

Hope that helps.

  • $\begingroup$ Having pulled out $k$ items for $A$, aren't there $2^{(n-k)}$ subsets that you could choose for $B$ so you would have $$\sum_{k=0}^{n} \binom{n-k+1}{k}2^{(n-k)}$$? It looks like your answer doesn't allow $B$ or $C$ to be empty and considers swapping $B$ and $C$ to be the same configuration. $\endgroup$ Feb 11, 2011 at 22:08
  • $\begingroup$ @Ross: $S(n,2) = 2^{n-1} -1$. I mentioned Strirling numbers because it generalizes to more sets :-) See here: en.wikipedia.org/wiki/… $\endgroup$
    – Aryabhata
    Feb 11, 2011 at 22:17
  • $\begingroup$ @Moron: yes, I had seen that, which is how I figured out the differences between the approaches. It depends what you want to count. $\endgroup$ Feb 11, 2011 at 23:18
  • $\begingroup$ @Ross: Multiplying by 2 and adding 2 is supposed to take care of swapping B and C, and empty sets. The formula($2^{n-1}-1$) then gives what you wrote in your comment, so it does seem to match... Am I missing something, or do we agree now? $\endgroup$
    – Aryabhata
    Feb 11, 2011 at 23:21
  • $\begingroup$ @Moron: we agreed all the time. And still do $\endgroup$ Feb 11, 2011 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy