Find the number of $7$-element subsets $\{a,b,c,d,e,f,g\}$ of $\{1,\cdots,14\}$ such that $7 \mid (a+ b+c+d+e+f+g)$ I would appreciate if somebody could help me with the following problem:
Q: Find the number of $7$-element subsets $\{a,b,c,d,e,f,g\}$ of $\{1,\cdots,14\}$ such that $7 \mid (a+ b+c+d+e+f+g)$
I think I've seen the above problem somewhere, but I can't remember. I want to see the solution again. Or please tell me how to approach it.
Study: After dividing 1 to 14 based on the remainder of dividing by 7, I tried an approach based on the number selected from each set, but I couldn't solve it because there were many trees or many cases.
 A: Here is a generating functions solution. Since all summands are distinct, their order does not matter, and we need to keep track of both the total sum and the size of the parts, we need the summands of the form $x^ky$ ($1$ part of size $k$) in the factors of the generating function. We can have $0$ or $1$ of copy of each part, so our factors are of the form $1+x^ky$, and our generating function is
$$
\prod_{k=1}^{14}(1+x^ky).
$$
The smallest possible sum divisible by 7 is $1+2+\dots+7=28$, and the largest possible sum $8+9+\dots+14=77$, so we need the sum of the coefficients of $\prod_{k=1}^{14}(1+x^ky)$ at $x^{7\ell}y^7$, where $4\le\ell\le 11$.
Expanding in Mathematica and adding up these coefficients in the order of increasing $\ell$, we get
$$
1+15+75+155+155+75+15+1=492.
$$
There is also an obvious symmetry here, induced by the map $x\mapsto 15-x$.
A: Here is a Starting Point :
Write the 14 numbers around a circle equally , clockwise , & also write the (Modulo 7) along with the numbers around the circle.
$01,02,03,04,05,06,07,08,09,10,11,12,13,14$
$01,02,03,04,05,06,00,01,02,02,04,05,06,00$
Now choose 7 elements which add up to a multiple of 7 , in other words $(0 \mod 7)$.
You can check that by rotating & selecting the successors of all the elements, you will still have a multiple of 7 , in other words $(0 \mod 7)$. This way you get more Solutions.
You can easily see that, given a Solution, you can always find at least 1 element which has 1 unused successor element clockwise.
If you exchange that element with the successor element, you will get 1 more than a multiple of 7, in other words $(1 \mod 7)$.
You can repeat this to get $(2 \mod 7)$ & $(3 \mod 7)$ etc.
Given a Solution, you can get more Solutions with the rotation & you can get more non-solutions with the increment.
This way , you can get all Possible 7-element subsets.
It is a simple matter to see how many 7-element subsets there are & how many 7-element subsets are with $(0 \mod 7)$, how many 7-element subsets are with $(1 \mod 7)$, how many 7-element subsets are with $(2 \mod 7)$, how many 7-element subsets are with $(3 \mod 7)$, ....
A: From : Find the number of all subsets of $\{1, 2, \ldots,2015\}$ with $n$ elements such that the sum of the elements in the subset is divisible by 5
The answer seems to be $\frac17\binom{14}7+\frac67\binom{2}{1} = 492$.
A: Here's a recursive approach.  For $i\in\{0,\dots,7\}$, $j\in\{0,\dots,14\}$, and $m\in\{0,\dots,6\}$, let $f(i,j,m)$ denote the number of $i$-subsets of $\{1,\dots,j\}$ whose sum is $m \pmod 7$.  Then
$$f(i,j,m) = \begin{cases}
1 &\text{if $i = 0$ and $m=0$} \\
0 &\text{if $i = 0$ and $m > 0$} \\
0 &\text{if $i > 0$ and $j = 0$} \\
\sum_{k=0}^1 f(i-k,j-1,m-jk \pmod 7) &\text{otherwise}
\end{cases}$$
You want to compute $f(7,14,0)$, which turns out to be $492$.

Alternatively, you can reduce the number of states and instead condition on the number ($0$, $1$, or $2$) of times that an element with a given $\bmod 7$ value appears.  For $i\in\{0,\dots,7\}$, $j\in\{0,\dots,6\}$, and $m\in\{0,\dots,6\}$, let $g(i,j,m)$ denote the number of $i$-sets with up to $2$ elements for each $\bmod 7$ value in $\{0,\dots,j\}$ and whose sum is $m \pmod 7$.  Then
$$g(i,j,m) = \begin{cases}
1 &\text{if $i = 0$ and $m=0$} \\
0 &\text{if $i = 0$ and $m > 0$} \\
\binom{2}{i} &\text{if $i > 0$, $j = 0$, and $m = 0$} \\
0 &\text{if $i > 0$, $j = 0$, and $m > 0$} \\
\sum_{k=0}^{\min(2,i)} \binom{2}{k} g(i-k,j-1,m-jk \pmod 7) &\text{otherwise}
\end{cases}$$
You want to compute $g(7,6,0)$, which turns out to be $492$.
