In how many ways can three numbers be selected from the numbers $1,2,\dots,300$ such that their sum is divisible by $3$? Can someone check which logic is finally correct?:
In how many ways can three numbers be selected from the numbers $1,2,\dots,300$ such that their sum is divisible by $3$?
I found different answers about the exact question but everyone states something different.
Dividing $\{1, \dots , 300\}$ into three groups $(A,B,C)$ where each one of them has $100$ numbers in it and ${}\bmod 3$ results in $0$ or $1$ or $2$ seems correct as a first step.
Then if we want the sum of the three numbers to be divisible by $3$ we should take cases:


*

*All of them belong to one of the groups: $ {{100}\choose{3}} + {{100}\choose{3}} + {{100}\choose{3}} $

*We take one from each group: $ {{100}\choose{1}} × {{100}\choose{1}} × {{100}\choose{1}} $


The answer ends there by adding the above numbers (because one of them can happen).
But what about combinations such as:
Taking one number from the group that gives remainder $1$ and two numbers from the group that gives remainder $2$??
 A: So we can choose the first two numbers how we like. The third has to have a definite residue class mod $3$ to make the total divisible by $3$.
If the third residue class is distinct from the residue class the first two numbers, the first two have to be from different residue classes. The number of ways of choosing one from each residue class is $\binom {300}1 \times \binom {200}1 \times\binom {100}1$, but there are six different orders in which the same three numbers can be selected.
If the final residue class is the same as one of the previous ones, they all have to be the same. We choose one of the three residue classes, and there are then $\binom {100}3$ ways of choosing a triple.
So the overall number of ways is $$\frac 16\times\binom {300}1 \times \binom {200}1 \times\binom {100}1+3\times\binom {100}3$$
And this is equal to $$\binom {100}1 \times \binom {100}1 \times\binom {100}1+3\times\binom {100}3$$
A: The remainders of these numbers must be only: $(0,0,0),(0,1,2),(1,1,1),(2,2,2)$. In every case you can chose ${100}\choose{3}$ triples. So you get $4\cdot {{100}\choose{3}}$ triples.  
There is a mistake in my reasoning. See the remark of Douglas S. Stones below (thank to him).
A: The combination of one number with remainder 1 and two numbers with remainder 2 gives a sum with remainder 2, so it is not a multiple of 3.  You listed the possibilities for getting a sum that is a multiple of 3 correctly.  At Thomas Andrews says, one of each group is the product of three ${100 \choose 1}$'s as you are choosing one from each group.
A: The number can be computed directly in GAP via:
Size(Filtered(Combinations([1..300],3),S->Sum(S) mod 3=0));

which returns 1485100.  This matches $3\binom{100}{3}+100^3$.
