6

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$??

user2692669
  • 317
  • 5
  • 15

4 Answers4

7

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$$

Mark Bennet
  • 100,194
4

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).

Boris Novikov
  • 17,470
2

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.

Ross Millikan
  • 374,822
1

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$.

  • Is there a matlab equivalent? – user2692669 Aug 31 '13 at 20:25
  • I'd say the answer to that question is yes (but I don't know what it is). – Douglas S. Stones Aug 31 '13 at 20:26
  • 1
    @DouglasS.Stones: Thanks! BTW, using iterator of combinations is slightly faster and less memory expensive, since it does not require to create the list of all 4455100 combinations first. Try n:=0; for s in IteratorOfCombinations([1..300],3) do if Sum(s) mod 3 = 0 then n:=n+1; fi;od; n; – Olexandr Konovalov Sep 02 '13 at 12:05