Exercise 2226Combinatorics › Counting principlesOlympiadAdded 4 Nov 2026
Subsets whose sum is divisible by p
#roots of unity filter#generating functions#counting#modular arithmetic
Statement
Let be an odd prime. Prove that the number of subsets of whose sum of elements is divisible by is
Hint
Let . Then equals if and otherwise. Apply this to the sum of each subset and exchange the order of summation.
Show solutionHide solution
Solution
Roots of unity filter. Let be the number we want. For a subset with sum ,
so
The term gives .
The terms . The residues modulo run over all residues exactly once, so
From at :
Conclusion.
Check. : . : . : .
Remark. As a corollary, , a proof of Fermat's little theorem for base .
Lesson. To count objects with a divisibility condition, average a root of unity over the residues.