# Two numbers $a$ and $b$ are chosen at random from the set of first 30 natural numbers.Find the probability that $a^2-b^2$ is divisible by $3$

Two numbers $a$ and $b$ are chosen at random from the set of first 30 natural numbers.Find the probability that $a^2-b^2$ is divisible by $3$.

Total number of ways of choosing two numbers out of 1,2,3....30 is $\binom{30}{2}=435$.So total cases are 435.

Note that $a^2-b^2$ is divisible by $3$ if and only if either (i) $a$ and $b$ are both divisible by $3$ or (ii) neither $a$ nor $b$ is divisible by $3$. This is because if $n$ is not divisible by $3$, then $n$ has remainder $1$ or $2$ on division by $3$. If $a$ and $b$ have the same remainder on division by $3$, then $3$ divides $a-b$. And if one has remainder $1$ and the other $2$, then $3$ divides $a+b$. Finally, $a^2-b^2=(a-b)(a+b)$.
There are $\binom{10}{2}$ choices of Type (i), and $\binom{20}{2}$ of Type (ii).
Alternately, we count the bad pairs, where one of the numbers is divisible by $3$ and the other is not. There are $(10)(20)$ bad pairs.
• They can be used. There are $\binom{30}{2}$ pairs, so there are $\binom{30}{2}-(10)(20)$ good pairs. – André Nicolas Sep 29 '15 at 15:07