[Math] Finding the integers between {1, 2, …, 100} that are divisible by 2 or 3 but not both.

discrete mathematics

I'm having trouble determining this problem.

I need to find the integers in the set {1, … , 100} that are divisible by 2 or 3 but not both.

The way I tried to approach it was:

If a number is divisible by both 2 and 3 then we can say it is divisible by 6. So we need to exclude integers divisible by 6. From here am I supposed to just go through each integer? Or is there a better way to approach this?

Thanks

Best Answer

Hint: In the set $\{1,\cdots, 100\}$, count the number of multiples of $2$. Then count the number of multiples of $3$, and add the two numbers together. Then subtract twice the number of multiples of $6$. Note that the number of multiples of $6$ is $\lfloor 100/6 \rfloor = 16$, since they are: \begin{align*} 6(1) &= 6, \\ 6(2) &= 12, \\ &~~\vdots \\ 6(16) &= 96 \end{align*}