[Math] Find sum of numbers from $1-100$ which are not divisible by $3$ and$ 7$

sequences-and-seriessummation

Question explains everything but I'm stuck at a certain part. I found:

  • sum of numbers from $1-100$
  • sum of numbers from $1-100$ divisible by $3$
  • sum of numbers from $1-100$ divisible by $7$

Then subtracted first sum by last $2$ sums as mentioned above but there are certain numbers that appear in both tables. Ex: $21$ in $3$ and $7$, next is $42$, $63$ and $84$
My question is how to find these numbers ? I can't check every number from $1-100$. Is there any formula for this ?

Best Answer

If you are familiar with unions and intersections of sets , then it is not a difficult problem.

Your answer should be: Total sum-(sum of multiple of $3 +$ sum of multiple of $7 -$ sum of multiple of $21)$

Since $21$ is LCM of $3$ & $7$

Related Question