The number of ways in which one can choose three distinct numbers from the set so that the product of the chosen numbers is divisible by $9$ 
Consider the set $A=\{1,2,3,...,30\}$
  . The number of ways in which one can choose three 
  distinct numbers from  $A$  so that the product of the chosen numbers is divisible by $9$  is $X$

Find $X$
This question is from KVPY SA 2017.
My working:
Nos in set divisible by $3$(but not by $9$)-$3,6,12,15,21,24,30$-Total $7$
Nos in set divisible by $9$-$9,18,27$-Total $3$
Therefore, the ans should be $7.7.20+7.7.7+7.7.3+7.3.3+3.3.3+3.20.20+3.3.20+3.7.20$
Where $.$ is multiplication
Is this correct?
 A: There are 10 numbers divisible by 3 viz. 3, 6, 9, 12 ... 30.
Case I : we have 2 of these 10 and one from remaining 20
10C2 X 20C1 = 900
Case II: we have all 3 numbers coming from these 10
10C3 = 120
Case III: Out of these 10, - (9, 18 and 27) are divisible by 9. We take only 1 number from these 3 and other 2 come from remaining 20
3c1 X 20C2 = 570
Total 900 + 120 + 570 = 1590
A: You haven't adressed "three distinct numbers" correctly. For instance, you aren't allowed to pick $3, 3, 5$, so the first term shouldn't be $7\cdot 7\cdot 20$, it should be $7\cdot 6\cdot 20$. And then, still, you count $3, 6, 5$ as a separate choice from $6, 3, 5$. Therefore, what you really want is $\frac{7\cdot 6}2\cdot 20$ for that term.
With these two corrections, the final answer is
$$
\frac{7\cdot 6}{2}\cdot 20 + \frac{7\cdot 6\cdot 5}{6} + \frac{7\cdot 6}{2}\cdot 3 + 7\cdot\frac{3\cdot 2}{2} + \frac{3\cdot 2\cdot 1}6 + 3\cdot \frac{20\cdot 19}2 + \frac{3\cdot 2}2\cdot 20 + 3\cdot 7\cdot 20
$$
A: We solve the opposite: let $Y$ denote the number of ways one can choose three distinct numbers for which their multiple not divisible by 9 i.e. divisible by 3 and not 9 or not divisible by 3 at all. First note that there are $10$ multiples of 3 among those $3$ are also a multiple of 9 in $\{1,2,...,30\}$ so the number of ways of choosing 3 numbers in case 1 is to choose exactly one multiple of 3 not of 9 to $7$  different ways and the others are chosen from the rest of the set providing $7\times 20\times 19$ different cases. The 2nd case also provides $20\times 19\times 18$ different cases and choosing three arbitrary number is possible to $30\times 29\times 28$ cases. So:$$X=30\times 29\times 28-20\times 19\times 18-7\times 20\times 19=14860$$If we don't mind ordering the answer would then be:$$X=\binom{30}{3}-\binom{20}{3}-\binom{7}{1}\binom{20}{2}=1590$$
