<s>[INST] 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?
 [/INST] 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$$
</s>