Find sum of numbers from $1-100$ which are not divisible by $3$ and$ 7$ 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 ?
 A: 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$
A: Sum of numbers divisible by $3=1683$
Sum of numbers divisible by $7=735$
Sum of numbers divisible by $21=210$
We need the sum of divisor of $21$ since if we subtract only by the Sum of divisor of $3$ and Sum of divisor of $7$ then the numbers those are divisible by both $3$ & $7$ means divisible by $21$ will be subtracted twice but we need to subtract it only once.
$\therefore$ The sum of numbers not divisible by $3$ & $7=$ Sum of first $100$ natural numbers $-$ Sum of divisor of $3-$ Sum of divisor of $7+$ Sum of divisor of $21$ 
$=5050-1683-735+210$ 
$=2842$
A: Number of multiples of $3$ between $1$ & $100$ = $[\frac{100}{3}]$ = $33$,
Number of multiples of $7$ between $1$ & $100 =$ $[\frac{100}{7}]$ = $14$,
Number of multiples of $21$ between $1$ & $100$ = $[\frac{100}{21}]$ = $4$,
Where $[x]$ is the box function.
Sum of first 100 terms excluding terms divisible by $3$ and $7$:
$$
S = \sum_{i=1}^{100} i - 3\sum_{i=1}^{33} i - 7\sum_{i=1}^{14} i + 21\sum_{i=1}^4 i.
$$
Apply the formula for $\sum_{i=1}^n i$ and take it from here.
A: Its simple find the sum of terms divisible by 21.
And add this sum.
Sum of first 100 terms excluding terms divisible by 3 and 7 = Sum of first 100 terms - Sum of terms divisible by 3 - Sum of terms divisible by 21 + Sum of terms divisible by 21.
Because when you are subtracting the sum of terms divisible by 3 and sum of terms divisible by 7 few terms which are divisible by both subtracted twice. So add sum of terms divisible by 21.

Update -  Answer with explanation.

Numbers divisible by 3 are 3, 6, 9, ...., 99.
Numbers divisible by 7 are 7, 14, 21, 28, ...., 98.
Numbers divisible by 21 are 21, 42, 63, 84.
Now we have sum of first 100 numbers not divisible by 3 and 7 is
(1 + 2 + 3 + .... + 100) - (3 + 6 + 9 + .... + 99) - (7 + 14 + 21 + .... + 98) + (21 + 42 + 63 + 84)
= (1 + 2 + 3 + .... + 100) - 3(1 + 2 + 3 + .... + 33) - 7(1 + 2 + 3 + .... + 14) + 21(1 + 2 + 3 + 4)
Using formula -
$$\sum_{k = 1}^{n} k = \tfrac{1}{2} (n)(n+1)$$
We have,
$ = \frac12 (100)(101) - 3 \cdot \frac12 (33)(34) - 7\cdot \frac12 (14)(15) + 21 \cdot \frac12 (4)(5)$
$= 5050 - 1683 - 735 + 210$
$= 2842$
A: First posted as a hint, but now it is the compilation to @Atul Mishra's answer.
Let us see what is happening in diagrammatic way:

Now, look at the image carefully.The coloured regions represent following data:
The rectangle: Sum of All the numbers from $1-100$.
White region: Sum of Numbers that are neither multiple of $3$ nor of $7$.
Green region: Sum of Numbers that are multiple of $3$ only.
Blue region: Sum of Numbers that are multiple of $7$ only.
Light blue region: Sum of Numbers that are multiple of $3$ and $7$.
We have to find the sum of numbers which are neither divisible by $3$ nor by $7$. So, we will find the sum of numbers that are in white region.
Sum of Numbers in white region $=$ Sum of Numbers in Rectangle $-$ Sum of Numbers in (Dark blue $+$ Light Blue) $-$ Sum of Numbers in (Green + Light Blue) $+$ Sum of Numbers in light blue region.
From here we get the formula used by other answers. i.e.,
Sum of Required numbers $=$ Sum of Total Numbers $-$ Sum of Numbers divisible by $7-$ Sum of Numbers divisible by $3+$ Sum of Numbers divisible by both $3$ and $7$.
Next question you may ask is that, How to find the sum of numbers from $1-100$ or sum of multiples of $3$ etc.
There is no problem in it, you just have to identify the A.P.
Sum of numbers from $1$ to $100$ equals  $\frac{100}{2}\times {101}$.
Sum of multiples of $3$ equals $\frac{33}{2}\times 102$.
......
......
......
I think I shall let you conclude now. :) :) :)
A: If you can use programmatic approach to answer your questions, which I personally find way easier than hand-written-math, you can check out that simple JavaScript fiddle I wrote for you.
In the right bottom corner you can find answers for you questions.
You can easily change code to, for example, find all numbers in range 100-1000 if you need to.
In that case, you would have to change line:
for (var i = 1; i <= 100; i++) {

to:
for (var i = 100; i <= 1000; i++) {


Every time you want your output to update, you have to click Run button at the top.
I'd gladly answer to any questions about code, if you have any.
Remember that the bottom right window won't wrap text, so the horizontal scrolling is possible.
