Maths WorkshopMaths problems with full solutions
Exercise 1256Combinatorics › Inclusion-exclusionOlympiadAdded 4 Nov 2026

Surjections and splitting a set into three groups

#Stirling numbers#inclusion-exclusion#surjections#set partitions

Statement

  1. Show that for n≥1n\ge1 the number of surjective maps from an nn-element set onto a 33-element set is 3n−3⋅2n+33^n-3\cdot2^n+3.
  2. Deduce the number S(n,3)S(n,3) of ways to split an nn-element set into 33 nonempty unlabelled groups, and show in particular that 3n−3⋅2n+33^n-3\cdot2^n+3 is divisible by 66.
  3. Prove also that S(n,2)=2n−1−1S(n,2)=2^{n-1}-1.
Hint

Count all maps and subtract those missing at least one value (inclusion-exclusion). Each partition into 33 groups corresponds to exactly 3!3! surjections.

Show solutionHide solution

Solution

1. Let the target be {1,2,3}\{1,2,3\}. There are 3n3^n maps. Let AiA_i be the set of maps never taking the value ii; ∣Ai∣=2n|A_i|=2^n, ∣Ai∩Aj∣=1|A_i\cap A_j|=1 for i≠ji\ne j, and ∣A1∩A2∩A3∣=0|A_1\cap A_2\cap A_3|=0 (as n≥1n\ge1). By inclusion-exclusion the number of maps missing no value is
3n−3⋅2n+3.3^n-3\cdot2^n+3.

2. A surjection ff gives the partition {f−1(1),f−1(2),f−1(3)}\{f^{-1}(1),f^{-1}(2),f^{-1}(3)\}, and each partition arises from exactly 3!=63!=6 surjections. Hence
S(n,3)=3n−3⋅2n+36,S(n,3)=\frac{3^n-3\cdot2^n+3}6,
which is an integer, so 6∣3n−3⋅2n+36\mid3^n-3\cdot2^n+3.

3. A map onto {1,2}\{1,2\} is surjective unless it is constant: 2n−22^n-2 surjections, and each partition into 22 groups comes from 22 surjections. So S(n,2)=2n−22=2n−1−1S(n,2)=\frac{2^n-2}2=2^{n-1}-1.

Check. For n=3n=3: 27−24+36=1\frac{27-24+3}6=1; n=4n=4: 81−48+36=6\frac{81-48+3}6=6; n=7n=7: 2187−384+36=301\frac{2187-384+3}6=301.

Remark. In general, the number of surjections onto a kk-set is ∑j=0k(−1)j(kj)(k−j)n=k! S(n,k)\sum_{j=0}^k(-1)^j\binom kj(k-j)^n=k!\,S(n,k).

Lesson. Count labelled objects (surjections) by inclusion-exclusion, then divide by the symmetry of the labels.