1

From a competition archive:

How many 7-subsets of $\{1,2,3,\dots,14\}$ are there, such that the sum of all the numbers in the subset is a multiple of 14?

The given answer is 246, which I have confirmed with some programming.

However, where does the answer come from? Less importantly, is there a general formula for this?

Some other questions I've read:

Number of ways to add up to a number without repetition (order does not matter)?
Number of ways to write a number $N$ as the sum of $M$ natural numbers, where order doesn't matter?
How many ways can a natural number n be expressed as a sum of one or more positive integers, taking order into account?

However, none of these have the answer that I want. I suspect there must be a neat trick using modulos or something. I've tried, but I can't quite figure it out.

Alex
  • 411
Samuel
  • 65
  • Generating function is the way to go in the general problem. Also, surely you mean $7$-subsets rather than subsets having this mysterious property called "length"? – user10354138 Oct 20 '23 at 13:38
  • @user10354138 all my life I thought subsets have lengths haha... Yeah, I meant 7-subsets – Samuel Oct 20 '23 at 14:01

1 Answers1

1

Take the generating function $$ G(x,y)=\prod_{n=1}^{14}(1+x^ny) $$ where $y$ is handing out a tag for "we select this number" and the $x$ is keeping track of the sum, so the coefficient of $x^ky^\ell$ is counting $\ell$-subsets that sum to $k$. Then extracting multiples of 14 from $x$ is easy --- just average over what you get from setting $x$ to be a $14$-th root of unity, and extract $y^7$-coefficient for $7$-subsets. In other words, just calculate \begin{align*} &[y^7]\frac1{14}\sum_{j=0}^{13}\prod_{n=1}^{14}(1+\zeta_{14}^{nj}y)\\ &=[y^7]\frac1{14}\sum_{j=0}^{13}\prod_{n=1}^{14/\gcd(14,j)}(1+\zeta_{14/\gcd(14,j)}^ny)^{\gcd(14,j)}\\ &=[y^7]\frac1{14}\sum_{d\mid 14}\phi(d)(1-(-y)^d)^{14/d}\tag{**}\\ &=\frac1{14}\sum_{d\mid 14}\phi(d)\underbrace{[y^7](1+(-1)^{d+1}y^d)^{14/d}}_{\neq 0\text{ only when }d\mid 7}\\ &=\frac1{14}\sum_{d\mid 14\text{ and }d\mid 7}\phi(d)[y^7](1+(-1)^{d+1}y^d)^{14/d}\\ &=\frac1{14}\sum_{d\mid 7}\phi(d)[y^7](1+(-1)^{d+1}y^d)^{14/d}\\ &=\frac1{14}\left(\phi(7)\binom{2}{1}+\phi(1)\binom{14}7\right)\\ &=246. \end{align*} where in (**) we collect the $j$s according to $d=14/\gcd(14,j)$ and use $\prod_{n=1}^d(1+\zeta_d^n y)=1-(-y)^d$.

user10354138
  • 33,887