4

I know that this has been posted before but I can't grasp how it actually works. I'm a 16 year old in the 10th grade and am interested in algorithms. I've looked in multiple places on the web but am unable to find a step by step breakdown of how this equation works. I want to understand the different parts. Thanks

Question: Find the sum of all the multiples of 3 or 5 below 1000

\begin{eqnarray} \sum_{k_{1} = 1}^{333} 3k_{1} + \sum_{k_{2} = 1}^{199} 5 k_{2} - \sum_{k_{3} =1}^{66} 15 k_{3} = 166833 + 99500 - 33165 = 233168, \end{eqnarray} where we have the used the identity \begin{eqnarray} \sum_{k = 1}^{n} k = \tfrac{1}{2} n(n+1). \end{eqnarray}

Original Post: Find the sum of all the multiples of 3 or 5 below 1000

1 Answers1

3
  • $\sum_{k_{1} = 1}^{333}3k_{1}$

Here you are sum up all numbers, which are multiples of 3: $3,6,9,12,**15**,18,21,...,**990**,993,996,999.$

$3\cdot 333=999$. That's why the upper bound is 333.

To calculate $\sum_{k_{1} = 1}^{333}3k_{1}$ you can factor out 3:

$\sum_{k_{1} = 1}^{333}3k_{1}$

Now you can use the identity to calculate it:

$$\sum_{k_{1} = 1}^{333}3k_{1}=3\cdot \frac{333\cdot(334+1)}{2}=3\cdot 333\cdot \frac{334}{2}=3\cdot 333\cdot 167=166833 $$

  • $ \sum_{k_{2} = 1}^{199} 5 k_{2}$

Here you are sum up all numbers, which are multiples of 5: $5,10,15,20,25,30,35,...,990,995.$

$5\cdot 199=995$. That's why the upper bound is 199.

You can see, that, for example, the numbers 15 and 990 are counted twice. You are counting all numbers twice, which are multiples of 15. Thus you have to substract them.

Finally, to know the upper bound of the third series, how many multiples of 15 should you subtract, divide 990 by 15 = 66.

callculus42
  • 31,012