Subjects number theory

Subset Sum Modulo

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Subset Sum Modulo


1. **Stating the problem:** Given $n$ integers $a_1, a_2, \dots, a_n$, we need to prove there exists a nonempty subset of $\{a_1, a_2, \dots, a_n\}$ whose sum is divisible by $n$. 2. **Define prefix sums:** Consider the prefix sums $S_k = a_1 + a_2 + \dots + a_k$ for $k=1, 2, \dots, n$. 3. **Consider modulo values:** Look at the values of $S_k \bmod n$, that is, the remainders when each prefix sum is divided by $n$. There are $n$ prefix sums, so we have $n$ values $S_1 \bmod n, S_2 \bmod n, \dots, S_n \bmod n$, each in the range $0$ to $n-1$. 4. **Apply pigeonhole principle:** If any $S_k \bmod n = 0$, then the sum $S_k = a_1 + a_2 + \dots + a_k$ is divisible by $n$. This subset $\{a_1, \dots, a_k\}$ is nonempty and satisfies the condition, so we're done. 5. **If none are zero:** If none of the $S_k$ are congruent to $0$ mod $n$, then all $n$ values $S_k \bmod n$ are from the set ${1, 2, \dots, n-1}$, which has $n-1$ elements. 6. **Pigeonhole principle again:** Since there are $n$ values $S_1 \bmod n, \dots, S_n \bmod n$ but only $n-1$ possible values, by the pigeonhole principle, at least two of these prefix sums share the same remainder mod $n$. Suppose $S_i \equiv S_j \pmod{n}$ with $i < j$. 7. **Forming the subset:** Then consider the subset $\{a_{i+1}, a_{i+2}, \dots, a_j\}$. Its sum is $$\sum_{k=i+1}^j a_k = S_j - S_i$$ and modulo $n$ this is $$S_j - S_i \equiv 0 \pmod{n}$$ which means the sum is divisible by $n$. 8. **Conclusion:** In either case, whether some $S_k \equiv 0$ or two are equal mod $n$, we find a nonempty subset of $\{a_1, \dots, a_n\}$ whose sum is divisible by $n$. **Final answer:** Such a nonempty subset always exists.