Find the number of sets $B$ such that $B \subset A$ , $|B|=m$, and the sum of the elements in $B$ is divisible by $p$. Let $A=\{1,2,\ldots ,p\}$ where $p$ is a prime number. Find the number of sets $B$ such that $B \subset A$ , $|B|=m$, and the sum of the elements in $B$ is divisible by $p$.
 A: 
if $p>2$ ,i had $\frac1p\binom{p}{m}$ correct?

Mostly. That formula doesn't work for $m = 0$ or $m = p$, in which case there is only one $m$-element subset - and the sum of that subset is $0$ resp. $\dfrac{p(p+1)}{2}$, so divisible by $p$ (for $p > 2$ prime).
For $1 \leqslant m \leqslant p-1$, the number of $m$-element subsets of $\{1,\,2,\,\dotsc,\,p\}$ whose sum is divisible by $p$ is indeed
$$\frac{1}{p}\binom{p}{m},$$
more, that is the number of $m$-element subsets whose sum is congruent to $k\pmod{p}$ for all $k$.
Let $S(m,k)$ be the set of all $m$-element subsets of $\{1,\,2,\,\dotsc,\,p\}$ whose sum is congruent to $k\pmod{p}$.
By adding $1$ to all elements of the subset (modulo $p$, so $p+1 = 1$), we obtain a bijection between $S(m,k)$ and $S(m,k+m)$, so $\lvert S(m,k)\rvert = \lvert S(m,k+m)\rvert$. Now, since $p$ is prime, and $1 \leqslant m \leqslant p-1$, the $p$ values $0 + q\cdot m,\; 0 \leqslant q < p$, cover all possible remainders modulo $p$, hence all $S(m,k)$ have the same cardinality.
The argument also works for composite $n$, if $\gcd(m,n) = 1$, then there are $\frac{1}{n}\binom{n}{m}$ subsets of $\{1,\,2,\,\dotsc,\,n\}$ of cardinality $m$ whose sum is congruent to $k\pmod{n}$ for every $0 \leqslant k < n$. It does not work when $\gcd(n,m) > 1$, and then the number of subsets depends on the remainder.
