[Math] Find the number of $2$-element subsets $\{a,b\}$ of $\{1,\cdots,1000\}$ such that $5 \mid a\cdot b$

combinatorics

Well, I have thought of two different solutions giving contradictory results, obviously one of them is wrong, or maybe both are wrong, but I can't see why. Please help me find the logical flaws or counting mistakes in my arguments.

The first alleged solution:

Since $5$ is a prime number, then $5 \mid a$ or $5 \mid b$. Without loss of generality, assume that $5 \mid a$. There are $200$ numbers in $\{1,\cdots,1000\}$ that are divisible by $5$. So, we have $200$ choices for $a$. On the other hand, the other number can be anything that we want, except $a$, because in that case the subset will be a singleton. So, we have $999$ choices for $b$. Therefore, there are $200 \times 999=199800$ such subsets.

The second alleged solution:

There are $200$ numbers that are divisible by $5$ in $\{1,\cdots,1000\}$. To find a $2$-element subset such that the product of its two elements is divisible by $5$ we can find the number of all $2$-element subsets such that the product of its elements is not divisible by $5$ and subtract this quantity from the number of $2$ element subsets of $\{1,\cdots,1000\}$:
$${1000 \choose 2} – {800 \choose 2} = \frac{1000(999)}{2} – \frac{800(799)}{2}=179900$$

Why these two numbers don't match? Aren't they supposed to be equal?!!

Best Answer

As Nate says in the comments: the sets where both $a$ and $b$ are divisible by 5 are counted twice as both numbers can play the role of $a$.

In order to correct for this we simply have to subtract off the number of these double counts which is the number of pairs $\{a,b\}$ with $a$ and $b$ divisible by 5 which is $$ \binom{200}{2} = 19900 $$ as you have noticed that there are 200 elements divisible by 5. When we have done this the answers then do agree and so both approaches are perfectly reasonable.

Related Question