i find this answer for 1-300 and sum is divisible by 3 i hope it can help you
In how many ways can three numbers be selected from the numbers 1,2,…,300
such that their sum is divisible by 3?
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 ${300 \choose 1} $${200 \choose 1} $${100 \choose 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 ${100\choose3}$
ways of choosing a triple.
So the overall number of ways is
$\frac{1}{6}×{300\choose1}×{200\choose1}×{100\choose1}+3×{100\choose3}$
And this is equal to
${100\choose1}×{100\choose1}×{100\choose1}+3×{100\choose3}$
you can find this answer here answer